【问题标题】:LINQ join from 3 differents tables来自 3 个不同表的 LINQ 连接
【发布时间】:2012-04-24 22:13:09
【问题描述】:

我有 3 张桌子

T1: id1, col1 (id1 is primary key)
T2: id2, id1, col2 (id1 here is  external key from T1)
T3: id3, id1, col3 (id external key of T1)

我的问题很简单:如何使用 LINQ 获得 3 个表的所有列的连接列表?

【问题讨论】:

标签: sql linq join


【解决方案1】:

我知道如何连接多个表的结果,这是一个示例,您可以根据需要连接任意多个表。

var a = (from s in _DBEntities.Services
         join d in _DBEntities.Departements on s.se_id_departement equals d.id_departement
         join i in _DBEntities.SsCategoriesServices on s.se_id_sscategorieService equals i.id_SsCategorieService
         select new Services
                    {
                        IdService = s.id_service,
                        Adresse = s.adresseService,
                        NomSousCategory = i.libelleSsCategorieService,
                        NomDepartement = d.nom,
                    }).ToList();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-15
    • 2014-11-16
    • 1970-01-01
    相关资源
    最近更新 更多