Upgrading from 2.6 to 3.1 TargetPerEntity

Posts   
 
    
chand
User
Posts: 72
Joined: 05-Aug-2007
# Posted on: 17-Jan-2012 18:15:45   

We are in the process of upgrading from 2.6 to 3.1 version of LLBLGenPro.

We have an entity Department with 1-n relationship with a targetperentity Employee. Employee has subtype of Manager Employee has another subtype of BoardMember

Our entity names are different but setup is identical to above hierarchy.

After the code generation the fetchcollection methods are failing with mult part identifier errors.

Basically query is complaining about unknown fields from Manager tables. This is because From clause doesn't include Manager/BoardMember tables

Following is the code from 2.6 version

var members = new EntityCollection<EmployeeEntity>(); var filter = new RelationPredicateBucket(EmployeeFields.DepartmentId== 1234);

filter.Relations.AddRange(InheritanceInfoProviderSingleton.GetInstance().GetInheritanceInfo(EntityType.EmployeeEntity.ToString(), false).RelationsToHierarchyRoot);

adapter.FetchEntityCollection(members , filter);

The same query now throwing multi part identifier errors

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Jan-2012 22:36:00   

I wonder why are you adding the inheritance relations by yourself. These are added automatically in the fetch. Remember that the polymorphic part is made by LLBLGen runtime under the hood. You just write as it was a normal fetch.

If you have more problems please provide the full exception message and stack trace.

David Elizondo | LLBLGen Support Team
chand
User
Posts: 72
Joined: 05-Aug-2007
# Posted on: 18-Jan-2012 16:20:38   

The hierarchy is not a typical one explained in documentation

Employee <- Manager Employee <- BoardMember

Department 1-n Employee

I tried removing that line of code that explicitly adding relationships in 3.1 compatible code.
I am still getting the wrong query. Manager table name is not in the FROM clause. There is nothing much in the exception other than Multi-Part identifier error.

If i changed the design to the following, it works fine! Query polymorphically fetches the correct records Employee <- Manager <- BoardMember

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 18-Jan-2012 16:50:22   

Please post the generated SQL for the following code:

var members = new EntityCollection<EmployeeEntity>();
var filter = new RelationPredicateBucket(EmployeeFields.DepartmentId== 1234);
adapter.FetchEntityCollection(members , filter);
chand
User
Posts: 72
Joined: 05-Aug-2007
# Posted on: 20-Jan-2012 17:43:03   

I think we ran into code generation conflicts while converting from 2.6 to 3.1. Lot of things weren't working right as 2.6 templates were modified heavily. I think we sorted out every thing and the query is fine.