Entity Framework prevent insert date between two dates


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:

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

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

>Solution :

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

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

Leave a Reply Cancel reply