IList<ExchangeSupplyData> chkDuplicate = context.ExchangeSupplyForecast
.select(i => i.RASchedulingPeriodID == schedulingPeriodId
&& i.RADlHdrID == record.DealNumberId
&& i.ProductClassID == record.ProductTypeId
&& i.SchedulingSubregionID == record.SubRegionId)
chkDuplicate will have the forecast's start and end dates of exchange supply. When a new forecast is added with the same schedulingPeriodId, DealNumberId, ProductTypeId , SubRegionId then the new start and end dates should not be in the existing forecasts start and end dates range. If the stat and end dates matches or in the range of existing records then I should return a bool to stop inserting the record.
How can I validate that in C# or LINQ? Can someone help me with this issue?
For example if we have two forecasts
First forecast's Start date: Nov 1st 2014, End date: Nov 7th 2014.
Second forecast's Start date: Nov 8st 2014, End date: Nov 17th 2014.
then If I try to add a new forecast the start date or end date should not be in the daterange Nov 1st 2014 to Nov 17th 2014