New Posts New Posts RSS Feed: Stored procedure non-query calls
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Stored procedure non-query calls

 Post Reply Post Reply
Author
kmg-pm View Drop Down
Newbie
Newbie


Joined: 04-Jun-2008
Location: United States
Posts: 8
Post Options Post Options   Quote kmg-pm Quote  Post ReplyReply Direct Link To This Post Topic: Stored procedure non-query calls
    Posted: 17-Apr-2009 at 1:43pm
I was wondering if it is possible in DevForceEF to call a stored procedure that is a non-query?
 
My stored proc does not return any data mapped to objects.  I was trying to figure out the how (and if) the "StoredProcRdbQuery" or "PassthruRdbQuery" classes worked in EF, but could find no documentation other than a brief mention in the Developers Guide.
 
Of course I could do this through a straight SQL/ADO mechanism, but I wanted to try and keep all of my DB interfacing through DevForceEF.
 
Any help would be greatly appreciated!
 
Thanks,
Kevin
Back to Top
davidklitzke View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 14-Jun-2007
Posts: 715
Post Options Post Options   Quote davidklitzke Quote  Post ReplyReply Direct Link To This Post Posted: 17-Apr-2009 at 4:22pm
You could use Remote Service Method Call (RSMC).  Read about this in Chapter 12 of the Developer's Guide.
 
The EntityManager has an InvokeServerMethod() method that facilitates the running of server-side-only methods.
Back to Top
pucsoftware View Drop Down
Groupie
Groupie
Avatar

Joined: 15-Apr-2008
Location: United States
Posts: 46
Post Options Post Options   Quote pucsoftware Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2009 at 10:49am
I have also created a stored procedure to deleted the relationship record in a many-to-many scenario. I originally tried doing this using the navigation properties of the parent objects but the response was really slow. So, I opted to try the old Import Function feature of the Entity Framework. This appears to work however I'm getting an exception in the DomainModel that I can't seem to capture (and handle/ignore) so it crashes my application. The exception reads:
 
"The data reader is incompatible with the specified [devforce class]. A member of the type, [key field], does not have a corresponding column in the data reader with the same name."
 
My code is using its class the signature of EntityManager.DefaultManager.MyDeleteMethod
 
It appears that the record is being deleted outside of the persistence cache and throwing an error because all of sudden the record no longer exists. The record is being deleted from the database, though. Is there a proper way to go about this? Can you explain what I should do about this?
 
 
puctx
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 25-Sep-2009 at 5:29pm
FunctionImports (and the DevForce StoredProcQuery) can only be used for queries, both by DevForce and by EF.  What's happening is that the proc is executed, but then DevForce will throw when trying to process its "results".  For the record, the PassthruEsqlQuery can also be used for queries only.
 
EF (and DevForce) does support DeleteFunctions, but expects you to load up the entity and call .Delete() on it; the stored proc is then called instead of the usual delete command when SaveChanges is called.  Probably not what you want, though, since it is slow to have to both load items and then individually delete them.  Here's some info on stored proc support in EF - http://msdn.microsoft.com/en-us/library/bb399203.aspx.
 
You can also define a cascading delete constraint, where a delete on the parent will automatically force deletion of the children, but again all items must already have been retrieved.
 
Your best option might be to use either ADO.NET or EF Object Services to directly call the stored proc.  If you want to run this only on the server you'll need to use InvokeServerMethod to call a custom method on the server.  Your next issue is then ensuring that what's in the EntityManager cache now corresponds with the DB -- EM.RemoveEntities may help with this.
 
 
 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down