New Posts New Posts RSS Feed: using stored procedure function mapping for updating data
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

using stored procedure function mapping for updating data

 Post Reply Post Reply
Author
bebe View Drop Down
Newbie
Newbie
Avatar

Joined: 11-Feb-2010
Location: Austria
Posts: 6
Post Options Post Options   Quote bebe Quote  Post ReplyReply Direct Link To This Post Topic: using stored procedure function mapping for updating data
    Posted: 02-Mar-2010 at 8:28am
In my model I'm mapping the update function to a stored procedure.

I assumed updating data via DevForce EntityManager would result in the same update statements as updating the data directly with EF. But it's not.
Have a look at this code and the generated update statements as comments:

            //use EF to update data

            using (var ctx = new Model.testEntities())
            {
                var t1 = ctx.Tests.First();
                t1.Value1 = "new value x";
                ctx.SaveChanges(); 
// -->   exec [dbo].[procTestUpdate] @ID=1,@value1='new value x',@value2='value2',@valueInt=1,@valueDate='2010-01-01 00:00:00'
            }
            
           
//use DevForce to update data
            var manager = DomainModel.DomainModelEntityManager.DefaultManager;           
            var t2 = manager.Tests.First();
            t2.Value1 = "new value y";
            manager.SaveChanges(); 
// --> exec [dbo].[procTestUpdate] @ID=1,@value1='new value y',@value2=NULL,@valueInt=0,@valueDate='0001-01-01 00:00:00'

In EF all values are passed to the stored procedure, regardless whether their value changed or not. Using DevForce only the values of the changed properties are passed and the others are null or default.

Is it posible to change this behavior? Is there any documentation and best practice about writing update procedures in "devforce style"?


Back to Top
IdeaBlade View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 30-May-2007
Location: United States
Posts: 353
Post Options Post Options   Quote IdeaBlade Quote  Post ReplyReply Direct Link To This Post Posted: 04-Mar-2010 at 2:52pm
This is a known issue which we plan to address in a future release. For performance reasons, DevForce only passes changes to the Entity Framework; but to accommodate an update via stored procedure, we'll need to seek out from the EF metadata that this is to be the mechanism, and then in that case change what we pass to EF.

The workaround is to communicate with the database directly using DevForce's AdoHelper class. You can find an example of that in the AllocateMoreIds() method in the NumericIdGenerator.cs (or .vb) file in the DevForce Learning Resources, at

     LearningResources\040_BusObjPersistence\AddingDeleting\Snippets\NumericIdGenerator
Back to Top
GregD View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 374
Post Options Post Options   Quote GregD Quote  Post ReplyReply Direct Link To This Post Posted: 18-Jun-2010 at 3:33pm
DevForce 2010 now support entities backed by stored procedures, as of version 6.0.3.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down