Linq relational table include

后端 未结 2 1676
感情败类
感情败类 2021-01-25 11:56

I have 4 relational table;

  1. Category
  2. Product
  3. ProductBrand
  4. ProductImage

I need linq query included 3 table

相关标签:
2条回答
  • 2021-01-25 12:10

    Use Include

    from b in db.ProductBrands.Include("Products.ProductImages") 
    where b.CategoryId == 5
    select b;
    

    Or the extension method Include.

    0 讨论(0)
  • 2021-01-25 12:14

    Instead of just select b, write like this select b.col1, i.col1, b.coln, i.coln....;

    The above will always return anonymous type object instead of a specific class...

    Thanks

    0 讨论(0)
提交回复
热议问题