views:

189

answers:

1

Based on a database myDB, I generate edmx for all table and compile the project. Then I create stored procedure myProc in myDB. Then I update the model by "Update Model from database" in the node Stored Procedure and add myProc. It is fine. Then "Create a function import" on myProc. It is fine. Then I compiled the project, it is fine.

The return type for this import function is scalars(string) because myProc return a string.

Then I want to use this function for this stored procedure, but I can find out the function. How to find out the matching function and call it in code?

+1  A: 

In EF 3.5 only functions that return Entities show up in ObjectServices.

I.e. importing pulls the Function into the Conceptual Model, but NOT into the code-generation.

We have addressed this problem in 4.0.

In the meantime you can call the function using eSQL.

i.e. something like this (pseudo code):

EntityConnection connection = ctx.Connection as EntityConnection;
//Open the connection if necessary
connection.Open()
//Create the command
EntityCommand command = new EntityCommand();
command.CommandText = "Function(@p1,@p2");
command.Parameters.Add(...);
command.Parameters.Add(...);
command.Connection = connection;
string s = command.ExecuteScalar().ToString();

Hope this helps

Alex

Alex James

related questions