Polymorphic FetchEntityCollection in LLBL 3.0

Posts   
 
    
garrett
User
Posts: 33
Joined: 21-Feb-2008
# Posted on: 07-Jul-2010 15:04:42   

I've a set small inheritance setup as follows

RoleEntity (abstract) - ContractEntity - PermanentEntity

I'm trying to fetch all roles regardless of type with the following :


            var roles = new EntityCollection<RoleEntity>();
            using (var adapter = new DataAccessAdapter()) {
                adapter.FetchEntityCollection(roles, null);
            }


but it bombing out with

System.MissingMethodException: No parameterless constructor defined for this object


Line 71:        public EntityCollection() : base( (IEntityFactory2)null )
Line 72:        {
Line 73:        }


So then I tried declaring the Entity Collection as:

var roles = new EntityCollection<RoleEntity>(new RoleEntityFactory());

But now I get an error that fieldindex '16' does not exist for PermanentRoleEntity.

Any pointers as to where I'm going wrong? Thanks!

Thanks Garrett

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Jul-2010 15:20:52   

Please make sure you are referencing the correct version of llblgen runtime library dlls and the latest generated code (or dlls).

garrett
User
Posts: 33
Joined: 21-Feb-2008
# Posted on: 07-Jul-2010 15:26:06   

I have 2.6 and 3.0 installed. Double checked that it was the 3.0 ORMSupportClasses dll that was being referenced. Any other ideas?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Jul-2010 15:27:25   

What about the generated code/projects?

garrett
User
Posts: 33
Joined: 21-Feb-2008
# Posted on: 07-Jul-2010 15:31:53   

both referencing the 3.0 ORMSupportClasses and Linq dll

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Jul-2010 15:32:46   

I mean that your application references the latest build of the generated projects. Bot older versions.

garrett
User
Posts: 33
Joined: 21-Feb-2008
# Posted on: 07-Jul-2010 15:38:45   

both projects (generic and specific) were generated from new within llbl 3.0

both projects are included in the same solution as the UI project (the calling application)

both projects are references as "project references" rather than absolute dll references

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Jul-2010 16:01:11   

Could you please attach a repro solution? (a very basic and simple one).

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 07-Jul-2010 16:35:16   

I could reproduce the error with the missing method exception. It is unfortunate, and a result of the way we determine the factory for the entity: it requires a ctor, which isn't there, as the entity is abstract.

The fieldindex which is missing is a bug we fixed recently. Please download the latest build from our website and this fieldindex issue should be resolved (you do have to re-generate the code, it's a problem in the templates).

So for abstract entities, you have to specify the factory in the ctor of the entity collection. This is required as the factory is obtained by creating an instance of the generic type of the collection, which is of course impossible if a ctor is missing which is the case with abstract types simple_smile

Frans Bouma | Lead developer LLBLGen Pro
garrett
User
Posts: 33
Joined: 21-Feb-2008
# Posted on: 08-Jul-2010 01:35:08   

Ok thanks Otis

I best upgrade my license too. Think my trial has run out.

Garrett