2014-10-03 3 views
0

가 나는 하위 개체의 집합을 포함하는 엔티티 (SystemUnit), (역할)가 아이 컬렉션 개체를 얻을 수 Id Asc (포함 된 역할 포함), id desc로 정렬. . 당신의 방법에 다음엔티티 프레임 워크는 자기 주문

public class entityContext{ 

    public DbSet<SystemUnit> SystemUnit { get; set;} 

} 

그리고 당신이 전화를해야합니다 LINQ (당신이 그것을 개체로 시스템 장치 개체를 추가하려면 먼저 다음 상황에 맞는 개체가 필요이를 위해

+1

[Entity Framework loading child collection with sort order] 가능한 복제본 (http://stackoverflow.com/questions/9938956/entity-framework-loading-child-collection-with-sort-order) – Dennis

답변

1

역할을 SystemUnit 개체에 따라 역할이 ORDERBY 12월 수 없습니다 이런 식으로 그래서 SystemUnit 객체가 이드 내림차순으로 정렬 한 경우 그들은 SystemUnit에 따라 검색합니다은

객체
+0

http://stackoverflow.com/questions/9938956/entity-framework-loading-child-collection-with-order-order 답변을 찾았습니다. –

0

에서 Newbee 예를 들어, 엔티티, 쓰기 :.. 포함

entityContext ec = new entityContext(); 
List<SystemUnit> systemUnit = (from su in ec.SystemUnit .Include("Roles") orderby su.Id Asc).ToList(); 
+0

예를 들어 주셔서 감사합니다.하지만 어떻게 할 수 있습니까? id desc로 정렬 한 역할을 포함합니까? –