Hi All,
I have a query (developing in linqpad):
DateTime currentDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
DateTime previousMonth = currentDate.AddMonths(-1);
DateTime previousMonthForAveragePrices = currentDate.AddMonths(-2);
var help = from cd in CostDrivers.OfType<Commodity>()
where cd.isActive == true &&
cd.arePricesCalculatedAverage == false
from cp in cd.CostDriverPrices where cp.priceDate
== currentDate
select new {cd.costDriverID, cd.costDriverName, cd.isUpdatedMonthly, cd.arePricesCalculatedAverage,
cp.costDriverPriceID, priceDate = cp.priceDate,
cp.price, previousPriceDate = from cpc in cd.CostDriverPrices where cpc.priceDate == previousMonth
select new {previousPrice = cpc.price, previousPriceDate = cpc.priceDate}};
help.Dump();
What i need to do is return ALL costDrivers regardless of whether a price record exists on the given date (currentDate). I should point out there is an attempt at a subquery to grab another price record for a the currentDate -1 month. I've tried || null etc. no go. This is linq to entities. The query itself works.. it will only return result where there is a price. thanks!
thanks.