私は2つのSQLクエリを持っています。私はlinqerを使用して変換しようとしましたが、結果はありません。このようなクエリ:LINQとSelect CountでSQLクエリを変換する
select distinct a.DOCID,
(select dcrea from mstdocs where DOCID = a.docid and vtype = 'table') DOC_DATE,
(select dcrea from mstdocs where DOCID= a.docid and vtype = 'read' and VTAID = '2') Read_DATE
from mstdocs a, mstdocstats b
where a.docid = b.docid
and a.vtaid = '2'
and a.vtype = 'read'
and DATEPART(mm,a.DCREA) = '06'
and DATEPART(yyyy,a.DCREA) = '2016'
and a.docid in
(
select distinct a.docid
from mstdocs a, mstdocstats b
where a.docid = b.docid
and a.vtype = 'table'
and DATEPART(mm,a.DCREA) = '06'
and DATEPART(yyyy,a.DCREA) = '2016'
)
select distinct a.docid
from mstdocs a, mstdocstats b
where a.docid = b.docid
and (select count(*) from mstdocs docs where docs.DOCID = a.docid and docs.vtaid = '2') = 1
私は最初のクエリはmstdocstats にBからの二つの部分
するvar A =(に分離変換しようとしているがa.docid上mstdocsに参加Bに等しいです。 DOCID a.vtype.Equals( "表") & & a.DCREA.Month == '06' & & a.DCREA.Year == '2016' a.docid).Distinct()を選択 。ToListメソッド();
するvar B =(mstdocstatsに がa.docidにmstdocsに参加Bはb.docid等しいからa.Contains(a.docid)は{新しい選択 DOCID = a.docid、 DOC_DATE =
Read_DATE =(mstdocからmstdocsでa.docid == mstdoc.docid、(a.docidは==
mstdoc.DCREAを選択& & mstdoc.vtype == "テーブル" をmstdoc.docid mstdocsでmstdocから) & & mstdoc.vtype == "read" & &
mstdoc.vtaid == "2" mstdoc.DCREAを選択)})。ToList();
でもエラーになりますが、間違いがどこにあるか教えてください。すべての答えを
おかげで...
はいフィールドdcreaはdatetimeですが、私はそのクエリをコンパイルし、結果は識別子が期待されています。 'in'はキーワードです。リストにそのクエリを格納したい場合は、distinct()の後にtolist()を付けることができますか? –
絶対にそうです..質問に –
のtoList()を追加することはできますが、結果はありません。理由はありません:( –