가격별로 제품 목록을 정렬하려고합니다.
결과 집합은 열별로 가격을 기준으로 제품을 나열해야합니다 LowestPrice. 그러나이 열은 널 입력 가능합니다.
목록을 내림차순으로 정렬 할 수 있습니다.
var products = from p in _context.Products
where p.ProductTypeId == 1
orderby p.LowestPrice.HasValue descending
orderby p.LowestPrice descending
select p;
// returns: 102, 101, 100, null, null
그러나 이것을 오름차순으로 정렬하는 방법을 알 수 없습니다.
// i'd like: 100, 101, 102, null, null
OrderByDescending, ThenBy더 명확합니다.
orderby그것을 찾고 측면 추적을 얻었다 :)
orderby p.LowestPrice ?? Int.MaxValue;간단한 방법입니다.