LINQに変換する次のSQLクエリがあります。私はOracleDBを使用しています。
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には1つの<->(1または0)があり、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,
};
SQL KERTY配列の最後の行をどのように記述できますか(つまり、
DECODE(TableD.Id,NULL,0,1) = some boolean variable)
構築したLINQクエリのwhere句で?
どうもありがとう...