Invalid object

Posts   
 
    
Posts: 34
Joined: 08-Nov-2007
# Posted on: 04-Dec-2007 19:14:53   

Self Service.. LLBLGEN 2.5, .Net 3.0. VS 2008. VISTA.

In my code I want to build a person before persisting him.

PersonEntity p1 = new PersonEntity(); p1.Name = "Fred";

PersonPhoneEntity personPhone = p1.Phone.AddNew();

This line throws "Invalid object name"

Looking at the inner exception QueryExecuted it looks like LLBLGen is trying to retrieve this collection from the database. I don't want this to happen, I want to build my Person and then called Save (true) at the end and it will save the Person first etc..

If its of any difference I'm not using seeds but GUIDs are primary keys on both tables

Posts: 34
Joined: 08-Nov-2007
# Posted on: 05-Dec-2007 00:48:38   

This can be closed, my silly mistake.

I had a project referencing two LLBLGen projects, both which used different DBs and of course both were configured to use the same appkey Main.ConnectionString doh! Changed the appkey of the second and problem resolved.. My bad frowning

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 05-Dec-2007 11:27:26   

Hint: Don't call AddNew() from your code, it's a databinding only method.

Instead you may use something like:

PersonEntity p1 = new PersonEntity();
p1.Name = "Fred";

PersonPhoneEntity personPhone = new PersonPhoneEntity();
personPhone.SomeField = ...;

personPhone.Person = p1;
p1.Save(true);