c# - Can Expression<Func<>> be used for projection in LINQ-To-Entities query syntax? -


i need re-use projection in multiple places in entity framework queries. projection needs access navigation properties, projection method has return expression<func<>>.

expression<func<inputtype, outputtype>> tooutputtype() {    return x => new outputtype    {        id = x.id,        parentname = x.navigationproperty.name     }; } 

this works fine when using method syntax.

var data = _repo.inputtypes.select(tooutputtype()); 

the resulting data iqueryable<outputtype>, should be.

but when used query syntax,

var data = (from x in _repo.inputtypes             select tooutputtype()); 

the resulting type iqueryable<expression<func<inputtype, outputtype>>>.

is not possible in query syntax?


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -