어떻게 다음 SQL 문을 LinqToSQL 문으로 변환 할 수 있습니까?SQL 문을 Linq로 변환
select field, 1 as ordering from table where field2 = condition1
union all
select field, 7 as ordering from table where field2 = condition2
union all
select field, 3 as ordering from table where field2 = condition3
union all
select field, 2 as ordering from table where field2 = condition4
order by ordering
실제로 몇 가지 쿼리에 참여하고 행의 출처를 기반으로 결과 집합을 정렬합니다.
다음과 같이 공용체를 관리 할 수 있지만 LinqToSQL을 전체 결과 집합으로 정렬 할 수는 없지만 각 개별 쿼리를 주문할 수만 있습니다. SQL에
from t in table
where
condition
select new { field, ordering = 1 }
).Union
(
from t2 in table2
where
condition
select new { field ordering = 7 }
).Union
(
from t3 in table3
where
condition
select new { field ordering = 3 }
).Union
(
from t4 in table4
where
condition
select new { field ordering = 2 }
);
그건 정확히 내가 한 것입니다. - 고마워요. – user9659