Thread ID: |
Created: |
Updated: |
Platform: |
Replies: |
143255 | Mar 11,2019 11:01 PM UTC | Mar 12,2019 07:21 AM UTC | ASP.NET MVC - EJ 2 | 1 |
![]() |
Tags: Schedule |
int intMax = db.ScheduleEventDatas.ToList().Count > 0 ? db.ScheduleEventDatas.ToList().Max(p => p.Id) : 1;
...
Id = intMax + 1,
this solution is not performant. I suggest this code:
int intMax = db.ScheduleEventDatas
.Select(x => x.Id).DefaultIfEmpty(0).Max();
This post will be permanently deleted. Are you sure you want to continue?
Sorry, An error occured while processing your request. Please try again later.
This page will automatically be redirected to the sign-in page in 10 seconds.