3
Answers

Conditional include in linq

Photo of mjasri

mjasri

4y
1.1k
1
I have the below code
 
//var result = (from hold in db.WcmHold
// where hold.Name.Contains(name)
// select hold).Where(x => managments.Contains(x.ManagemntId)).Include("DocumentsImage").Include("FieldsDescription").OrderByDescending(x=>x.CreatDate).Take(100).ToList();
 
I want to show/Include just the "DocumentsImage"  that there Id>=1000
 

Answers (3)

1
Photo of Laxmidhar Sahoo
NA 10.4k 55.7k 4y
Hi
 
From my understanding you have two tables one is WcmHold and another is  managments,
 
On which table id based you want to retrieve the data .again what is the common key for both tables
 
Thanks and regards 
1
Photo of Jay Krishna Reddy
14 53.3k 5.4m 4y
  1. var result = Table.Where(c=>c.Id >= 1000).Select(i=>i.DocumentsImage).ToList().  
Thanks.
1
Photo of Jignesh Kumar
29 39.6k 2.9m 4y
Hi Majsri,
Please use below  links which will help you,
https://entityframework.net/include-with-where-clause 
https://www.codeproject.com/Questions/898509/how-to-do-more-conditional-includes-in-linq-to-ent