Abstract Entities as CLR abstract classes

Posts   
 
    
ianbanks
User
Posts: 9
Joined: 21-Sep-2005
# Posted on: 07-Apr-2006 14:07:58   

Hello,

Is there any reason when a class included in an inheritance hierarchy in LLBLGen Pro isn't marked abstract when the C# templates are generated?

The reason it came up is because I'm using inheritance to represent a tree of accounts; leaf accounts are "posting accounts" and have a real balance, and non-leaf nodes are summary accounts and don't have real balances. The balance of a summary account is the sum of all posting accounts that are grand children of the summary account node.

If the abstract Account class were marked as abstract in the CLR, I could declare an abstract method to get the balance and then implementations in the concrete classes.

If I edit the base entity and mark it abstract everything compiles and works; is there any reason the templates aren't marked abstract in the templates that ship?

Regards, Ben

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 07-Apr-2006 15:53:01   

The fetch logic has to determine the hierarchy type, which is done through an entity instance, as the entity instance has access to the inheritanceinfoProvider of the particular project. (the call originates from the adapter core in the ormsupportclasses, which don't have access to that object). This 'dummy' instance can't be created if the class is abstract, so the class is made public though the constructor is made internal.

Frans Bouma | Lead developer LLBLGen Pro
Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 07-Apr-2006 16:28:21   

You can mark an entity as an Abstract by using the Designer, right-click an Entity and select IsAbstract

Please check the "Abstract entities" sections under "Concepts -> Entity inheritance and relational models" in the LLBLGen Pro documentation manual.

Also please refer to the following thread: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=4678