Is it possible to specify "Includes" from a List please?
I have a list of possible sub tables to be included in:
List<string> includedTables
My current database call looks like this:
return db.SA_Items
.Where(x => x.LastUpdated > lastUpdated)
.Where(x => x.Active == true)
.OrderBy(x => x.ItemID)
.Skip(offset)
.Take(limit)
.ToList();
I would to somehow to a foreach string in the List and add a .Include(....)
to the database call...
Say, for example, if there were 2 strings in the list the code would be equivalent to this:
return db.SA_Items
.Include("first string in the list")
.Include("second string in the list")
.Where(x => x.LastUpdated > lastUpdated)
.Where(x => x.Active == true)
.OrderBy(x => x.ItemID)
.Skip(offset)
.Take(limit)
.ToList();
It's also possible that the List might be null.
Is it possible to do this dynamically somehow?
Can anyone give me any pointers please?