首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

多表关联,该怎么处理

2012-02-05 
多表关联C# codevar result from s in stockjoin r in report on s[ProductId] equals r[ProductId]

多表关联

C# code
    var result = from s in stock                         join r in report on s["ProductId"] equals r["ProductId"] into sr                         join p in product on s["ProductId"].ToString().ToLower() equals p["ProductId"].ToString().ToLower() into rp                        

看代码,不废话,这里s是主表,但是我现在又要关联1个表w,这个表里面有一个字段跟r表里面字段warehouseid关联,可是这里r不是主表,根本不能关联到,请问用什么办法管理这两个副表呢,本人小菜,希望原谅。


[解决办法]
上面有个错
C# code
var result = from s in stock              join r in report on s["ProductId"] equals r["ProductId"] into sr              from srs in sr.DefaultIfEmpty()               join p in product on s["ProductId"].ToString().ToLower() equals p["ProductId"].ToString().ToLower() into rp              from rps in rp.DefaultIfEmpty()              join w in w_table on srs.warehouseid equals w.ID into wr              from wrs in wr.DefaultIfEmpty() 

热点排行