2013-12-18 7 views
0

에 의해 새로운 객체 순서를 만들 :LINQ 내가 새로운 객체를 생성이 쿼리와 특성

   var allData = from op in _opg 
          join tp in _tpg on op.DataGiorno equals tp.DataGiorno 
          join ts in _tsg on op.DataGiorno equals ts.DataGiorno 
          select new {op, tp, ts}; 

주요 소스, 는 "_opg는"가 목록입니다>. 기본적으로 "op"이 DateTime 유형이므로이 새로운 객체를 "op" 오름차순으로 주문합니다. 힌트가 있습니까?

답변

1

당신은 단지 LINQ 쿼리에 orderby 절을 추가 할 수 있어야한다 :

var allData = from op in _opg 
       join tp in _tpg on op.DataGiorno equals tp.DataGiorno 
       join ts in _tsg on op.DataGiorno equals ts.DataGiorno 
       orderby op ascending 
       select new {op, tp, ts} 

이것은 IComparable<[type of op]>을 구현하는 연산의 유형을 필요로한다.

관련 문제