Define a sub-query in a Model-Defined Function in Entity Framework -


is possible define subquery in model-defined function in entity framework? have situation have customer object has history of names in table. want return current name part of customer object.

the model-defined function might this:

<function name="currentname" returntype="edm.string">    <parameter name="e" type="model.customer"/>    <definingexpression>       (select top(1) n.legalname entities.customernames n order n.effectivedate desc )   </definingexpression>   </function> 

unfortunately, above doesn't work. error of:

the result type 'edm.string' specified in declaration of function 'snccmodel.currentlegalname' not match result type 'transient.collection[transient.rowtype(legal_name,edm.string(nullable=true,defaultvalue=,maxlength=512,unicode=false,fixedlength=false))]' of function definition

any suggestions? supposed work? sorry, refactoring our data model store recent name in customer table not option.

thanks, rick

try following query:

anyelement(select value top(1) n.legalname entities.customernames n order n.effectivedate desc )

basically query returning collection of rows, , expected result type string. specifying select value, rid of row (and project collection of strings), , wrapping in anyelement, flatten structure , return single element result collection (in case, element).


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -