This probably extends the boundaries of Linq-to-Sql a bit, but considering how versatile it is so far, I thought I'd ask.
I have 3 queries that select identical information and differ only in the where clause, now I know that I can pass a delegate, but this only allows me to filter the results that have already been returned, but I want to create a query through to ensure efficiency.
Here is the request:
from row in DataContext.PublishedEvents join link in DataContext.PublishedEvent_EventDateTimes on row.guid equals link.container join time in DataContext.EventDateTimes on link.item equals time.guid where row.ApprovalStatus == "Approved" && row.EventType == "Event" && time.StartDate <= DateTime.Now.Date.AddDays(1) && (!time.EndDate.HasValue || time.EndDate.Value >= DateTime.Now.Date.AddDays(1)) orderby time.StartDate select new EventDetails { Title = row.EventName, Description = TrimDescription(row.Description) };
The code that I want to apply using the parameter will be as follows:
time.StartDate <= DateTime.Now.Date.AddDays(1) && (!time.EndDate.HasValue || time.EndDate.Value >= DateTime.Now.Date.AddDays(1))
Is it possible? I do not think that is all, but I thought that I would look first.
thanks
source share