Enetity framework IQueryable, with 2 queries
I wanted to ask if there is a better way to achieve what I'm trying to do.
I need to get all the records of a child graph that have the date greter
or equal to the given date, and the first record with date minor to the
given date.
I found this solution that works but I'm not sure that this will be the
best way.
var q = context.Istc0.Include("Interests").Where(a => a.IIsin ==
listKey).Select(a => new
{
Istc0 = a,
Interests = a.Interests.Where(d => d.InDat >= date)
});
var qq = context.Istc0.Include("Interests").Where(a => a.IIsin
== listKey).Select(a => new
{
Istc0 = a,
Interests = a.Interests.Where(d => d.InDat <
date).OrderByDescending(d => d.InDat).Take(1)
});
var xxx = q.ToList()[0].Istc0;
xxx = qq.ToList()[0].Istc0;
return xxx;
Thank you very much
No comments:
Post a Comment