Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Bugs & Issues> RelationPredicateBucket not working for UpdateEntitiesDirectly
 

Pages: 1
Bugs & Issues
RelationPredicateBucket not working for UpdateEntitiesDirectly
Page:1/1 

  Print all messages in this thread  
Poster Message
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
65 posts
# Posted on: 07-Jan-2013 22:49:31.  
I'm using runtime version 3.5.12.1101, 2-class Adapter, SQL Server.

I have an entity B that is in an inheritance hierarchy (target per entity). It inherits from entity A. I am trying to update entity B using UpdateEntitiesDirectly, passing a RelationPredicateBucket specifying the key fields of the entity so the update is restricted to a single record.

If, in the entity instance I pass to the method, I have only updated fields that are defined in entity B, it works correctly. However, if I also update one or more fields that are inherited from A, it does not work correctly.

Specifically, LLBLGen issues two database updates. The first statement updates the table for A, and that includes the WHERE clause generated from the RelationPredicateBucket. However, the second statement, which updates the table for B, does not include the WHERE clause, so it updates all rows in the table.

  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8071 posts
# Posted on: 08-Jan-2013 05:57:17.  
I reproduced it with latest LLBGen Framework, using InheritanceOne db.

RTL
ORMSupportClasses: 3.5.12.1220

Code
Code:
var newValues = new ManagerEntity();
newValues.ManagesDepartmentId = 1; // at Manager target
newValues.StartDate = DateTime.Now; // at Employee target

var filter = new RelationPredicateBucket();
filter.PredicateExpression.Add(ManagerFields.EmployeeId == 2);

using (var adapter = new DataAccessAdapter())
{
    adapter.UpdateEntitiesDirectly(newValues, filter);
}


Generated SQL
Code:
#1
UPDATE [InheritanceOne].[dbo].[Employee]
SET    [StartDate] = @p1
FROM ( [InheritanceOne].[dbo].[Employee]
         LEFT JOIN [InheritanceOne].[dbo].[Manager]
             ON [InheritanceOne].[dbo].[Employee].[EmployeeID] = [InheritanceOne].[dbo].[Manager].[ManagerID])
WHERE ((([InheritanceOne].[dbo].[Manager].[ManagerID] = @p2)))

#2
UPDATE [InheritanceOne].[dbo].[Manager]
SET    [ManagesDepartmentID] = @p3


We will look into this. In the meantime, as a workaround use the traditional fetch-modify-save approach.


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37476 posts
# Posted on: 08-Jan-2013 09:51:11.  
Hmm, this is a nasty bug! Dissapointed Looking into it now.

(edit) in batch updates, it simply doesn't append the filter for the second and so on queries. It does append the PK filter, so updates of subtypes work but batch updates don't. This issue has been in the code since before v2.0. Bizarre that it's not been reported (nor did we find it) till today!
Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
Otis
LLBLGen Pro Team



Location:
The Hague, The Netherlands
Joined on:
17-Aug-2003 18:00:36
Posted:
37476 posts
# Posted on: 08-Jan-2013 11:08:12. Goto attachments  
Fixed. See attached dll.

Frans Bouma
LLBLGen Pro / ORM Profiler Lead Developer | Blog | Twitter
 
Top
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
65 posts
# Posted on: 08-Jan-2013 16:39:05.  
Thanks as always for the quick fix.
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.