如何排序entity framework返回的内部列表?

如何对entity framework返回的对象的内部集合进行排序?

public class X { public string Field {get; set;} public EntityCollection Ys {get; set;} } public class Y { public string Field {get; set;} } from x in entities.Xs orderby x.Field select x 

有没有办法修改这个LINQ查询以返回X对象,还有Y对象排序? 或者我必须在它返回时手动对Y列表进行排序?

编辑:

此代码必须返回X类型对象的集合,匿名键入不符合当前项目的要求。

 var sortedList = from x in entities.Xs orderby x.Field select new { Field = x.Field, y = (select y in x.Ys orderby y.Field select y) }; 

编辑:如果您不想要匿名类型,请执行以下操作:

 var sortedList = from x in entities.Xs orderby x.Field select new X { Field = x.Field, y = (select y in x.Ys orderby y.Field select y) };