3
我有以下類別:排序母公司
public class Order
{
public int Oid {get; set;}
public DateTime OrderDate {get; set;}
public List<OrderDetails> OrderDetails {get; set;}
}
public class OrderDetail
{
public int Oid {get; set;}
public int Price {get; set;}
public Order Order {get; set;}
public EventSchedule EventSchedule {get; set;}
}
public class EventSchedule
{
public int Oid {get; set;}
public BaseEvent BaseEvent {get; set;}
public List<OrderDetail> OrderDetails {get; set;}
}
public class BaseEvent
{
public int Oid {get; set;}
public string Name {get; set;}
public List<EventSchedule> EventSchedules {get; set;}
}
我有以下代碼:
var result = Database.Orders.Where(o => o.DateTime == dateTime);
現在,我要排序的result
:
case "Date":
result = (sortingOrder == "desc") ? result.OrderByDescending(c => c.OrderDate) : result.OrderBy(c => c.OrderDate);
break;
// the problem is here this code not works
case "EventName":
result = (sortingOrder == "desc") ? result.All(o=>o.OrderDetails.OrderBy(d=>d.EventSchedule.BaseEvent.Name)) : ...;
break;
該Order
有一個OrderDetail
的集合。 OrderDetail
有EventSchedule
。並且,EventSchedule
有BaseEvent
。這是可能Order
對象由Name
財產在BaseEvent
?