日期:2014-05-20  浏览次数:20943 次

Lint to Sql 查询包含对不同数据上下文上所定义项的引用
C# code

private CustomerDataContext dc = new CustomerDataContext();
private SysDataContext ds = new SysDataContext();
public IEnumerable<MiddleSellerOrg> SelectSellerOrgBySellerID(string SellerID)
        {
var q = from a in dc.Cust_SellerOrgs
                    join b in ds.Sys_Organizations on a.OrgID equals b.OrgID
                    where a.SellerID == SellerID
                    select new MiddleSellerOrg { 
                    ..........
                    };
return q.ToList();
}


dc.Cust_SellerOrgs 和ds.Sys_Organizations 是多对多的关系

怎么改,网上找了很多,但不知道怎么改

------解决方案--------------------
不支持多个DataContext的连接!若有疑问!请QQ(252377274)帮你解决
------解决方案--------------------
转化成Linq2Object查询:
C# code

private CustomerDataContext dc = new CustomerDataContext();
private SysDataContext ds = new SysDataContext();
public IEnumerable<MiddleSellerOrg> SelectSellerOrgBySellerID(string SellerID)
        {
var q = from a in dc.Cust_SellerOrgs.ToList()
                    join b in ds.Sys_Organizations.ToList()
                    on a.OrgID equals b.OrgID
                    where a.SellerID == SellerID
                    select new MiddleSellerOrg { 
                    ..........
                    };
return q.ToList();
}