Custom task performer for grouping entities

Posts   
 
    
chiro
User
Posts: 6
Joined: 15-Apr-2010
# Posted on: 21-Apr-2010 11:07:58   

Hi,

i am trying group CRUD methods i generate for each entity. For example, i would like to group all CRUD methods for users, userAccounts, userRights etc in a single file e.q. UserAdministration. I have prefixed my database tables in such a way. Could you please give me some directions on how do I accomplish that? Or example with building custom task performer and accessing entity/table data from it? Thanks in advance.

Walaa avatar
Walaa
Support Team
Posts: 14986
Joined: 21-Aug-2005
# Posted on: 21-Apr-2010 12:02:13   

Would you please elaborate in more details?

Which CRUD methods are you speaking about? Are you using SelfServicing or Adapter?

Do you mean something like manager templates?

chiro
User
Posts: 6
Joined: 15-Apr-2010
# Posted on: 21-Apr-2010 12:32:03   

Here is my problem in more details:

i am using adapter. I have written template which generates static CRUD methods for each entity, like: InsertUser, UpdateUser, DeleteUser, GetUser, GetAllUsers etc. Those are generated in a new file per entity, e.g. UserEntityCrud.cs which holds all those methods specific to UserEntity. Now, i would like to group those methods, to generate just one file per group of entities. For example, i would like to generate UserAdministration.cs file which will hold those methods for UserEntity, those methods for UserAccount entity, those methods for UserRight entity, separated by region. I would also like to generate another file, e.g. GameAdministration.cs which will hold those CRUD methods for entities like Game, GameRule, and so on. I put prefixes in my database table names, e.g. 'u' for user group, like: uUser, uUserAccount, uUserRight, 'g' for tables related to games, like: gGame, gGameRule and so on. I know I can strip those prefixes when generating entities in llbl, and i am doing so. Now I need a task performer which will generate those files (UserAdministration, GameAdministration...) using those database tables prefixes to define in which group to put CRUD methods for some entity. Could you please help me with that, with some informations, links, examples which show how can I generate new task performer, and within it how can i loop through each entity, resolve its database table name (to get prefix, like 'u' for users) to know in which file I should generate those methods., resolve entity name and stuff like that. I would appreciate this very much, because i am googling whole morning without much success. I thank in advance!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39767
Joined: 17-Aug-2003
# Posted on: 22-Apr-2010 11:30:07   

Our template system generates either 1 file per task or files based on a set of elements, e.g. all entities -> 1 file per entity.

This means that it doesn't generate a file based on logic determined inside the template. If you want that, you've to create your own task performer by either altering the code in an existing one (using the SDK) or deriving from one and overriding some methods.

You can obtain the target an entity is bound to by examining the EntityDefinition object and checking the 'MappedTarget' of the entity. please see the SDK and the reference manual for the designer which comes with the reference docs for the classes you work with in a template and task performer (you've to use .lpt templates)

However, as in v3 we changed the inner api completely (as it's a different model) and task performers are refactored to re-use a lot of the code, it's perhaps advisable to keep what you have now: the methods per entity. The point is that if an entity moves group, the crud methods also have to move from one code file to another, while with a class per entity this isn't the case: your code using the methods doesn't have to change and writing the code is easier: you can use the crud methods defined in the type related to the entity they work on.

Frans Bouma | Lead developer LLBLGen Pro
chiro
User
Posts: 6
Joined: 15-Apr-2010
# Posted on: 23-Apr-2010 13:57:29   

thanks, I will wait till v3 so I don't have to write it twicesimple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39767
Joined: 17-Aug-2003
# Posted on: 23-Apr-2010 14:36:04   

chiro wrote:

thanks, I will wait till v3 so I don't have to write it twicesimple_smile

You can start today, you can obtain the beta from the customer area as well as the beta license simple_smile

Frans Bouma | Lead developer LLBLGen Pro