Abstract entities not abstract

Posts   
 
    
worldspawn avatar
worldspawn
User
Posts: 321
Joined: 26-Aug-2006
# Posted on: 21-Feb-2008 06:41:31   

Hey folks,

I've flagged an entity as abstract in the designer but it's not being marked as abstract in the generated code. Using latest 2.0 build... (adapter/.net 2.0)

I get: public partial class PolicyEntity : EntityBase2, ISerializable, IPolicy

(The IPolicy is an extra interface that put's in via the designer)

As you can see there's no abstract keyword in the class definition.

I've attached my project file.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 21-Feb-2008 10:09:25   

By design, abstract entities need to be instantiated by the internal engine for example when fetching all the entities of that type (and subtypes). The ctor is internal though.

worldspawn avatar
worldspawn
User
Posts: 321
Joined: 26-Aug-2006
# Posted on: 22-Feb-2008 00:26:58   

So... what does that mean? It's not supposed to put the abstract keyword in the class definition? What's the point of it then?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 22-Feb-2008 10:13:44   

A class containing an internal constructor cannot be instantiated outside of the assembly. An internal constructor can be used to limit concrete implementations of the abstract class to the assembly defining the class.

So from your application you can not instantiate from that entity class.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 22-Feb-2008 16:54:59   

The runtime needs to create a dummy instance of an entity to determine the fields. If you fetch for example 'employees' where employee is an abstract entity, it has to produce an entity instance. that's why the ctor is internal so the factory can instantiate one, the rest can't.

Frans Bouma | Lead developer LLBLGen Pro