Harlem 98

Harlem 98

  • NA
  • 161
  • 18.9k

Add + 1 to LastOrDefault

Dec 13 2021 4:25 PM

Hello community.

I'm doing an insert form, and i'm trying to use a LastOrDefault to get the new value, and creating a new one binding it +1 , but i don´t know how to trasnlate this programatically.  Could you help me?

//LastOrDefaultpublic ListagemTimesheet CreateNewID(int ID){using (GestaoProjectosEntities lt = new GestaoProjectosEntities()){return lt.ListagemTimesheets.LastOrDefault(a => a.ID == ID);}}//form.CSint idtimesheet = int.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString()); //find for an existing ID
ListagemTimesheet timesheet = listagembll.CreateNewID(idtimesheet); //LastOrDefault //Create a new ID ?

 


Answers (3)