그냥 TSQL에서 같은 : DataTable을 주문하는 방법 AsEnumerable()을 사용하는 둘 이상의 조건에서 OrderBy?
select * from aTable where (aCondition) order by AnIntegerField desc, ADateField
는 DataTable을 사용하여 정렬 방법 :
는
dt.AsEnumerable().OrderBy(--two conditions --)
그냥 TSQL에서 같은 : DataTable을 주문하는 방법 AsEnumerable()을 사용하는 둘 이상의 조건에서 OrderBy?
select * from aTable where (aCondition) order by AnIntegerField desc, ADateField
는 DataTable을 사용하여 정렬 방법 :
는
dt.AsEnumerable().OrderBy(--two conditions --)
당신은 처음있는 OrderBy을 사용 후 ThenBy (오름차순) 또는 (내림차순) ThenByDescending. Microsoft 설명서에서
는 :string[] fruits = { "grape", "passionfruit", "banana", "mango",
"orange", "raspberry", "apple", "blueberry" };
// Sort the strings first by their length and then
//alphabetically by passing the identity selector function.
IEnumerable<string> query =
fruits.OrderBy(fruit => fruit.Length).ThenBy(fruit => fruit);
또는 VB에 대한
(질문부터 모두 태그가) :' Create an array of strings.
Dim fruits() As String = _
{"grape", "passionfruit", "banana", "mango", _
"orange", "raspberry", "apple", "blueberry"}
' Sort the strings first by their length and then
' alphabetically by passing the identity function.
Dim query As IEnumerable(Of String) = _
fruits _
.OrderBy(Function(fruit) fruit.Length) _
.ThenBy(Function(fruit) fruit)
데이터 테이블이 크고 최상의 성능이 필요합니다. .Select()를 사용하는 것보다 낫다고 생각하십니까? – Alaa
@Ala 정렬을 위해 '선택()'을 사용할 수 없습니다. – svick
내 연구에 따르면 @svick, 나는 AsEnumerable(). OrderBy()를 사용하는 것이 성능을 고려할 때 Select()보다 훨씬 낫다는 것을 발견했다. 이 질문에서'Select()'를 언급하십시오. 저는 여기에있는 대답이 정확하다고 믿지만 사실 두 종류를 구현하고 있습니다. Select()보다 빠르다고 생각하십니까? 이 문제에 대한 다른 질문. – Alaa
당신은'AsEnumerable()가'모든 정렬이 완료되는 것을 의미합니다 것을 깨닫는다 메모리 내? – svick
@svick, 예, 기억합니다. – Alaa