Function Import missing from ObjectContext

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
jdaly
Posts: 3
Joined: Fri 20 Jun 2008 01:48

Function Import missing from ObjectContext

Post by jdaly » Fri 20 Jun 2008 03:00

According to the ADO.NET Entity Framework I should be able to invoke a stored proc via the ObjectContext. I have followed the steps of including a sproc in my entity model and creating a function import for it, but I cannot see a method on my ObjectContext class to enable me to invoke the sproc in code. Am I missing something? How am I supposed to call the sproc once I have included it in the entity model?

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Mon 23 Jun 2008 11:52

Hello,

using stored procedure in OraDirect .NET and Oracle server is the same as with MS SQL server.
As soon as you generated the edmx file (with SP) open it in Model Browser.
Then perform the following steps:
- select a table that you want to update with a SP
- click on Mapping Details window (View -> Other Windows -> Mapping Details)
- in the top left corner of the window click on the bottom picture (Map Entity to Functions)
- select the needed function, in my case "Insert Using DEPT_INSERT"
- map the SP parameters to the table columns

That's all. Then you simply call an AddTo*** method and save the changes.

Regards,
Alexey.

jdaly
Posts: 3
Joined: Fri 20 Jun 2008 01:48

Post by jdaly » Tue 24 Jun 2008 03:43

Thanks Alexey, very helpful.

I also am trying to work out how to invoke a sproc via the ObjectContext which just does a SELECT, and can't figure that out. Is there a way?

The reason I want to do this is to invoke a sproc which returns the result from a call to GetNextID on an oracle sequence, to use to populate a primary key property on a new object prior to calling save on the context.

And the reason I want to do that is because our DBA is nervous about us using triggers on inserts to populate primary keys on the table.

I was expecting to be able to write code like this:

Code: Select all

using(MyObjectContext ctx = new MyObjectContext())
  long ID = ctx.GetNextID();
where "GetNextID" is mapped to a sproc.

Alexey.mdr
Posts: 729
Joined: Thu 13 Dec 2007 10:24

Post by Alexey.mdr » Tue 24 Jun 2008 15:12

Hello,

We investigated the problem.
Well, currently this feature (Function Import) is not properly implemented in EDM designer.
We are looking for a solution.
This may take some time.
Probably we will wait for the EF release.

Regards,
Alexey.

Anchor
Posts: 31
Joined: Mon 08 Dec 2008 21:02
Location: Massachustts/USA

Function Import missing from ObjectContext

Post by Anchor » Tue 10 Feb 2009 21:21

Can someone tell me where we are with this topic?

I am trying to do something similar. I want to call a stored procedure that takes a couple of strings but have it just return an integer or a collection of integers.

When I try to add the stored procedure, through the Function Import, I cannot add this stored procedure to my context. Is there a software patch or a work-around?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 11 Feb 2009 13:04

Microsoft supports Function Imports only for Stored Procedures returning result set.
There is no way to create Function Import for the procedure you described using ADO.NET Entity Data Model Designer.
But we are working on a tool which will give an opportunity to solve this and many other problems.

Anchor
Posts: 31
Joined: Mon 08 Dec 2008 21:02
Location: Massachustts/USA

Post by Anchor » Tue 23 Jun 2009 15:08

I know I am a little late of this topic but I just wanted to comfirm something.

When you say "Microsoft supports Function Imports only for Stored Procedures returning result set" you mean the Visual Studio IDE/Entity Framework does not support "function imports" returning nothing or scalar types, only Entities. So even though VS 2008 allows you to select "None" or "Scalar Type" for a return type when creating a function import, the entity framework does not support it. Correct?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 24 Jun 2009 06:48

Correct.
The Microsoft code generation does not support Function Imports that do not return resultset.
You can try Devart Entity Developer, our code generation provides such support.

Anchor
Posts: 31
Joined: Mon 08 Dec 2008 21:02
Location: Massachustts/USA

Post by Anchor » Wed 24 Jun 2009 13:16

Yes. A co-worker here downloaded it and I was surprise to see it that it worked and not Microsoft's EDM IDE. (I guess I shouldn't have been surprise. ;-) )

I might use your Entity Developer in the future given that Microsoft's next release might not be for a while. However, what do I do if I have a EDM developed using Microsoft's IDE? Will your Entity Developer work with a Microsoft .edmx file?

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 24 Jun 2009 13:50

You can open an .edmx file using Entity Developer and save it as an .edml file.

Post Reply