请考虑以下查询语句:
在这个查询中,请查看
表中的一对多关系类似于:
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
,这两个都是我从Opportunity表中获取的,是否有其他方法可以获得这两个字段。表中的一对多关系类似于:
ProspectProfile -> Opportunities
是否我编写的查询可以使用或者还有其他更简单的方法。