これはLINQへの私の最初の進出です。 私はまだ結果の部分の周りに私の頭を包んでいるが、私はこれから任意の結果を得るように見えることはできません。LINQクエリで結果が表示されない - WHERE句とのLEFT結合
var institutions = from lots in lotsdb.NEWinstitution
join webs in webbitdb.tblinstitution
on lots.institutionid equals webs.dispenseinstid into newinsts
from webs2 in newinsts.DefaultIfEmpty()
where webs2 == null
select new
{
instid = lots.institutionid,
instname = lots.institutionname
};
foreach(var instfound in institutions)
{
MessageBox.Show(instfound.instid.ToString() + " " + instfound.instname.ToString());
}
私は、Visual StudioによってDATASourcesリストで作成されたデータセットを使用しています。 IsInstitutionIdNull()
方法はときMSDataSetGeneratorによって生成される
var institutions =
from lots in lotsdb.NEWinstitution
join webs in webbitdb.tblinstitution on lots.institutionid equals webs.dispenseinstid
where webs.IsInstitutionIdNull()
select new
{
instid = lots.institutionid,
instname = lots.institutionname
};
:以下
は、私はあなたがおそらくこのようなものが必要LINQ にstring strgetloc = @"
SELECT NEWinstitution.institutionid, NEWinstitution.institutionname
FROM NEWinstitution
LEFT JOIN tblinstitution
ON NEWinstitution.institutionid = tblinstitution.dispenseinstid
WHERE (((tblinstitution.institutionid) Is Null));"
本当に空のものだけが必要ですか? 'where webs2 == null' –
私はLINQの例をcanabalisingしています。これは間違っていると思います。 lotsdb.NEWinstitution.institutionidが必要です。webbitdb.tblinstitution.institutionidがNULLです –
このクエリが結果を返すのは確かですか?あなたはSQLサーバーで類似した実行しようとしましたか? – gh9