Linq. Select from multiple tables

前端 未结 2 1694
野性不改
野性不改 2020-12-30 03:20

In project I have this tables:

  1. Product(id,catalogId, manufacturerId...)
  2. Catalog
  3. Manufacturer

Also Product model

2条回答
  •  情话喂你
    2020-12-30 03:36

    To combine results from multiple tables without explicitly joins:

    from p in Product
    from c in Catalog
    from m in Manufacturer
    where c.Id == p.CatalogId && m.Id == p.ManufacturerId && p.Active == 1
    select new 
        { 
            p.Name,
            p.CatalogId,
            p.ManufacturerId,
            c.Name,
            m.Name 
        };
    

提交回复
热议问题