Home > Software engineering >  Entity Framework prevent insert date between two dates
Entity Framework prevent insert date between two dates

Time:01-16

In my project user can select 2 dates startDate and endDate. The selected startDate must be greater than the largest endDate stored in SQL Server:

enter image description here

How can I check this using an Entity Framework Linq statement?

 _context.tableName.where(p => p.startDate >= ??);

CodePudding user response:

Something like this could work for you, adapt it to your needs

if (startDate > _context.tableName.Max(p => p.endDate))
  • Related