I have a LINQ query that uses 1 table + a large number of views. I'd like to be able to write something like this:
IQueryable<Guid> mostViewedWriters;
switch (datePicker)
{
case DatePicker.Last12Hours:
mostViewedWriters = from x in context.tempMostViewed12Hours
select x.GuidId;
break;
case DatePicker.Last24Hours:
mostViewedWriters = from x in context.tempMostViewed24Hours
select x.GuidId;
break;
case DatePicker.Last36Hours:
mostViewedWriters = from x in context.tempMostViewed36Hours
select x.GuidId;
break;
}
var query = from x1 in context.Articles
join x2 in context.Authors on x1.AuthorId == x2.AuthorId
join x3 in mostViewedWriters on x2.AuthorId == x3.Id
select new { x2.AuthorName, x1.ArticleId, x1.ArticleTitle };
The above C# is pseudo-code written to protect the innocent (me). The gist of the question is this: I have a query that is related to the results of a view. That view, however, could be one of many different views. All the views return the same data type. I thought that I might be able to create an IQueryable that would contain the Ids that I need and use that query. Alas, that effort has stalled.