using stored procedure function mapping for updating data
Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1665
Printed Date: 24-Oct-2025 at 4:57pm
Topic: using stored procedure function mapping for updating data
Posted By: bebe
Subject: using stored procedure function mapping for updating data
Date 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"?
|
Replies:
Posted By: IdeaBlade
Date 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
|
Posted By: GregD
Date Posted: 18-Jun-2010 at 3:33pm
|
DevForce 2010 now support entities backed by stored procedures, as of version 6.0.3.
|
|