I have a list on SharePoint, where I am trying to load fields for this list like following:
var lists = context.Web.Lists; context.Load(lists, n => n.Include(x => x.Title, x => x.Fields.Include( z => z.Title, z => z.InternalName, z => z.TypeDisplayName))); context.ExecuteQuery();
The following part of the code I use quite often in my code, while working with other lists:
x => x.Fields.Include( z => z.Title, z => z.InternalName, z => z.TypeDisplayName)
I would like to know if there is a way how to simplify inserting this
.Include statement in my code (so that in case I will have to add more properties in the future, I dont have to rewrite all my code everywhere but only in one place).
I have tried to create custom LINQ Extension, but it failed as it is probably expecting sort of a
Expression<Func<T,Y>> (I guess).
Any help regarding this matter would be more than appreciated!