Suppose I have the following line of code:
context.Load(itemCollection, item => item.Include(i => i["Title"], i => i["Name"]));
Is there any way I can dynamically specify the parameters to the item.Include()
function instead of hard-coding them as above?
I would ideally like to allow users to select properties they want to retrieve of an object such as Title
, Name
, Description
, etc.
FYI, here is the ClientContext.Load
function. This function is coming from Microsoft.SharePoint.Client.dll
public void Load<T>(T clientObject, params Expression<Func<T, object>>[] retrievals) where T : ClientObject
{
if ((object) clientObject == null)
throw new ArgumentNullException("clientObject");
ClientAction.CheckActionParameterInContext(this, (object) clientObject);
DataRetrieval.Load<T>(clientObject, retrievals);
}