UpdateMulti and "object reference not set to an instance of an object" error

Posts   
 
    
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 19-Mar-2012 17:41:31   

Hi, after updating to 3.5 i started getting the error in subject line.

nothing has been changed on my end and the only difference is updating from 3.1 to 3.5.

here is the code:

var users = new UserCollection(); trans.Add(users); var userUpdate = new UserEntity { AddressId = addressId}; IPredicateExpression filter = new PredicateExpression(UserFields.UserId == selectedUserIds); users.UpdateMulti(userUpdate, filter);

there seems to be no sql generated. i get the exception in the last line where it says users.UpdateMulti(userUpdate, filter);

is this a result of a 3.5 breaking change?

thanks -shane

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39909
Joined: 17-Aug-2003
# Posted on: 19-Mar-2012 20:27:50   

stacktrace please.

Frans Bouma | Lead developer LLBLGen Pro
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 19-Mar-2012 22:08:58   

Otis wrote:

stacktrace please.

at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.UpdateMulti(IEntity entityWithNewValues, ITransaction containingTransaction, IPredicate updateFilter, IRelationCollection relations) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\DaoBase.cs:line 1268 at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.UpdateMulti(IEntity entityWithNewValues, IPredicate updateFilter, IRelationCollection relations) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityCollectionBase.cs:line 603 at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase1.UpdateMulti(IEntity entityWithNewValues, IPredicate updateFilter) in c:\Myprojects\VS.NET Projects\LLBLGen Pro v3.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\SelfServicingSpecific\EntityCollectionBase.cs:line 560 at CSSIS.Core.BL.UserManager.UpdateAddresses(List`1 selectedUserIds, String addressLine1, String city, String state, String zipCode, Transaction trans) in D:\Users\SNP\Documents\Visual Studio 2010\Projects\CS-SIS\Tier-BL\Module-Core\UserManager.cs:line 212

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Mar-2012 05:12:31   

Reproduced. From the stack trace I guess your UserEntity is a subType in a TargetPerEntity hierarchy.

ORMSupportClasses RTL: 3.5.12.0317

**Code **(using InheritanceOne database)

[TestMethod]
public void UpdateMultiWithInheritanceCrash()
{
    var clerks = new ClerkCollection();
    var trans = new Transaction(IsolationLevel.Serializable, "UpdateMultiTx");
    trans.Add(clerks);

    var selectedClerkIds = new List<int>();
    selectedClerkIds.Add(1);
    selectedClerkIds.Add(2);

    var customerUpdate = new ClerkEntity { JobDescription = "Everything..." };
    IPredicateExpression filter = new PredicateExpression(ClerkFields.EmployeeId == selectedClerkIds);

    clerks.UpdateMulti(customerUpdate, filter);         
}

StackTrace: same as above

We are looking into this...

David Elizondo | LLBLGen Support Team
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 20-Mar-2012 05:53:31   

Acually UserEntity is the superType in a TargetPerEntity hierarchy.

-shane

daelmo wrote:

Reproduced. From the stack trace I guess your UserEntity is a subType in a TargetPerEntity hierarchy.

ORMSupportClasses RTL: 3.5.12.0317

**Code **(using InheritanceOne database)

[TestMethod]
public void UpdateMultiWithInheritanceCrash()
{
    var clerks = new ClerkCollection();
    var trans = new Transaction(IsolationLevel.Serializable, "UpdateMultiTx");
    trans.Add(clerks);

    var selectedClerkIds = new List<int>();
    selectedClerkIds.Add(1);
    selectedClerkIds.Add(2);

    var customerUpdate = new ClerkEntity { JobDescription = "Everything..." };
    IPredicateExpression filter = new PredicateExpression(ClerkFields.EmployeeId == selectedClerkIds);

    clerks.UpdateMulti(customerUpdate, filter);         
}

StackTrace: same as above

We are looking into this...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39909
Joined: 17-Aug-2003
# Posted on: 20-Mar-2012 10:01:22   

Interestingly... our updatemulti tests with inheritance work.

Looking into it.

(edit)... I can't reproduce it... confused David's exact test works OK.... Trying different tests... orm dll and generated code is the right version (v3.5, latest build code)

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39909
Joined: 17-Aug-2003
# Posted on: 20-Mar-2012 10:12:49   

I can't reproduce it, with 2-class scenario.

I'll try with normal selfservicing classes. The problem is the 'name' of the entity isn't set, and with 2-class scenario the name IS set properly (hence the code works), and as it's a template related problem, it might be the CTor's in the normal selfservicing classes are not correct.

(edit) I see the problem indeed... it's with the normal selfservicing classes (so the 2-class scenario works properly). Bug in template. Will look into it.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39909
Joined: 17-Aug-2003
# Posted on: 20-Mar-2012 10:43:30   

Fixed in next build. See attached template for temp fix.

Place as administrator in folder: <llblgen pro install folder>\Frameworks\LLBLGen Pro\Templates\SharedTemplates\Net2.x\C#

VB.NET works OK.

Attachments
Filename File size Added on Approval
entity.template 12,410 20-Mar-2012 10:43.39 Approved
Frans Bouma | Lead developer LLBLGen Pro
e106199
User
Posts: 175
Joined: 09-Sep-2006
# Posted on: 20-Mar-2012 14:29:49   

thank you. i am glad you've nailed it.

Otis wrote:

Fixed in next build. See attached template for temp fix.

Place as administrator in folder: <llblgen pro install folder>\Frameworks\LLBLGen Pro\Templates\SharedTemplates\Net2.x\C#

VB.NET works OK.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39909
Joined: 17-Aug-2003
# Posted on: 20-Mar-2012 15:21:08   

New build has been uploaded. simple_smile

Frans Bouma | Lead developer LLBLGen Pro