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
Post a Comment