c# - how to read the parameter with params keyword and implementing a function -
hi have here code snippet. isn't mine, saw in net while learning on how deal entity framework
know including (eager load) navigation properties homecoming iqueryable
what want know is:
how read parameter params system.linq.expressions.expression<func<t, object>>[] includeproperties
?
how phone call or utilize function? (should pass collection, right? little illustration great help since larn in way when see demo)
public iqueryable<customer> allincluding(params system.linq.expressions.expression<func<t, object>>[] includeproperties) { var query = context.customers; foreach (var includeproperty in includeproperties) { query = query.include(includeproperty); } homecoming query; }
any help much appreciated. thanks!
params
lets pass array parameter actual array or open-ended list of values:
var includes = new expression<func<customer, object>>[] { => i.subproperty1, => i.subproperty2 }; var query = db.entities.allincluding(includes);
or just
var query = db.entities.allincluding(i => i.subproperty1, => i.subproperty2);
i'm guessing on specific types , properties, idea.
c# entity-framework
No comments:
Post a Comment