1

我想将此查询转换为 linq,请帮助:

select 
  mr_ssample.objectid,
  mr_ssample.stcode 
from mr_ssample 
inner join mr_wsample  on mr_ssample.objectid = mr_wsample.objectid 
                      And mr_ssample.stcode in( select stcode 
                                                from mr_wsample)  

我在 C# 中试过这个

var query = from ssamp in marineEntity.MR_SSAMPLE
                        join wsamp in marineEntity.MR_WSAMPLE on ssamp.OBJECTID equals wsamp.OBJECTID && ssamp.stcode.contains(wsamp.stcode)
                        select new
                        {};

但是,我无法访问wsampcontains或者我不知道这个的替代方案。

4

1 回答 1

2

试试这个,

var _result =   from  a in mr_ssample
                join  b in mr_wsample on a.objectid equals b.objectid
                where (from c in mr_wsample select new  {c.stcode})
                       .Contains(new {a.stcode})
                select new {a.objectid, a.stcode}
于 2013-03-12T07:26:18.630 回答