考虑以下查询:LINQ到实体查询
var profilelst =
(
from i in dbContext.ProspectProfiles
where i.CreateId == currentUser
select new ProspectProfile
{
ProspectId = i.ProspectId,
Live = i.Live,
Name = i.Name,
ServiceETA = i.Opportunities.OrderByDescending(t => t.FollowUpDate)
.FirstOrDefault()
.ServiceETA.ToString(),
FollowUpDate = i.Opportunities.OrderByDescending(t => t.FollowUpDate)
.FirstOrDefault()
.FollowUpDate
}
)
.ToList();
return profilelst.OrderByDescending(c=>c.FollowUpDate)
.Skip(0).Take(endIndex)
.ToList();
在这里,在此查询,请看看FollowUpDate
和ServiceType
,这些都我有机会表取回,有没有其他的解决办法得到这些既..
一对多的关系在表像:ProspectProfile -> Opportunities
无论我写的查询是好的或有任何其他解决办法,可以在更简单的方式来完成。
重新格式化的代码使其可读,但是,实际问题并不清楚。 –
您是否测试过您的第一个查询是否可用?我怀疑。 – Slauma