The use of stored procedures (SPS) in the EDM seems to me to be more concerned with the performance of the SP in the edmx file than the SP's functionimport in the EDM.
After I add the stored procedure SP GetOrder to the EDM and finish FunctionImport, I can open the edmx file to view the implementation of GetOrder in SSDL (), Csdl,c-s mapping:
SDL: <function name= "GetOrder" aggregate= "false" builtin= "false" niladicfunction= "false" iscomposable= "false" parametertypesemantics= "allowimplicitconversion" schema= "dbo" >
<parameter name= "OrderID" type= "int" Mode = "in"/>
</Function>
About parameters in function: For iscomposable,builtin These 2 parameters are very important to specify that the return result will be returned by the query of the stored procedure, without generating additional SQL (for LINQ, no need to be interpreted in time) because it is set to false. There's nothing else to say.
CSDL: <functionimport name= "getorders" entityset= "Orders" returntype= "Collection (northwindefmodel.orders)" >
<parameter name= "OrderID" mode= "in" type= "Int32"/>
</FunctionImport>
ReturnType is a collection, I tried to modify it to a single entity (let it return a non-collection type), but it is not supported in the EF v1.
If the SP is just that in the edmx file, there's really nothing to write about. But not only that, because there are commandtext,out put arguments in addition to return type.
. CommandText
There is a CommandText tag underneath the XML node of the function, which allows us to customize SQL in the function of the SSDL layer, rather than just the SP, where it is better to embed SQL in the SSDL layer in some specific scenarios than SP, After all, the SP exists on the database, which makes it necessary to manage the data not only for the application but also for the CommandText attribute in the function 2 to achieve some sort of balance. Here are examples of using CommandText
ssdl:<function name= "Customerwithhighestsales" aggregate= "false" builtin= "false" niladicfunction= "false" Iscomposable= "false" parametertypesemantics= "allowimplicitconversion" schema= "dbo" > <!--cannot use command tex T with functions. Allows to execute multiple statement.--> <CommandText> select * from Customers where custo Merid = (select top 1 o.customerid from the Orders o join OrderDetails od on o.orderid = od. OrderID GROUP BY O.customerid Order by SUM (OD. UnitPrice * od. Quantity) desc </CommandText> </Function> CommandText content in SSDL is to find Highestsales's customer Csdl: <f Unctionimport name= "Customerwithhighestsales" entityset= "Customers" returntype= "Collection" ( northwindefmodel.customers) "> </FunctionImport> msdl: <functionimportmapping functionimportname=" Customerwithhighestsales "Functionname=" NorthwindEFModel.Store.CustomerWithHighestSales/>