我需要在带有导航属性的 EntitySQL 查询中使用 MAX 和 GROUP BY。我有以下查询。我需要选择表'APPROVALS'的导航属性中存在的最新'CREATED'列的记录。
请帮忙查询。
public IQueryable<TravelRequest> GetTravelRequestswithChildrenForGuid(Guid ID)
{
IQueryable<TravelRequest> v = this.ObjectContext.TravelRequests
.Include("CarRentals").Include("CarRentals.CarRentalType")
.Include("Approvals").Include("Approvals.ApprovalType")
.Include("Accomodations")
.Include("TravelRequestStatus").Where(t => t.RowGuid.Equals(ID));
foreach (TravelRequest t in v)
{
t.Flights.Clear();
foreach (Flight f in GetFlightsForTravelRequest(t.RowGuid))
{
t.Flights.Add(f);
}
}
return v;
}