1
LINQ로 변환 할 다음 SQL 쿼리가 있습니다. Oracle DB를 사용하고 있습니다. TableC는 선택 사항입니다> (하나 영) -LINQ의 Where 절 내부에서 If 문 사용
SELECT TableA.Id,
TableA.Date,
TableA.ItemId
TableB.Quantity,
TableB.Total
FROM TableA, TableB, TableC, TableD
Where TableA.Id = TableB.Id and
TableA.Id = TableC.Id (+) and
TableA.Id = TableD.Id (+) and
TableA.ItemId = _itemId and
TableA.Date >= _from_date and
TableA.Date < _to_date and
DECODE(TableD.Id,NULL,0,1) = (some boolean variable)
TableA의와 TableC 하나 < 있습니다.
내가 쓴 LINQ 쿼리는 다음과 같습니다
var data = from ta in context.TableAs
join tB in context.TableBs
on tA.Id equals tB.Id
join tD in context.TableDs
on tA.Id equals tD.Id into A
from itemA in A.DefaultIfEmpty()
join tC in context.TableCs
on itemA.tA.Id equals tC.Id into B
from itemB in B.DefaultIfEmpty()
where itemA.tA.ItemId == _itemId &&
itemA.tA.Date >= _startDate &&
itemA.Ta.Date< _endDate && // this is where I got stuck...
select new
{
itemA.tA.Id,
itemA.tA.Date,
itemA.tA.ItemId,
itemA.tB.Quantity,
itemA.tB.BalanceQuantity,
};
내 건설 LINQ 쿼리의 where 절에서 SQL QUERTY의 마지막 줄 (즉
DECODE(TableD.Id,NULL,0,1) = some boolean variable)
을 쓸 수있는 방법
?많은 감사 ...
는이처럼 쓸 수 있습니다 : td.Id ?? 참된. 나는 이드가 당신의 데이터베이스에 비트 타입이라고 가정한다. –