we need to generate business objects by default for the entity objects

Posts   
 
    
vairam2008
User
Posts: 86
Joined: 11-Mar-2008
# Posted on: 18-Mar-2008 00:33:37   

we need to generate business objects by default for the entity objects. Need example to create templates for our requirement to map with WPF controls. How to do it?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 18-Mar-2008 09:53:23   

What do you mean with 'business objects' ?

Templates are described in detail in the SDK, which is available to customers. Though I don't think you really need business objects, the entities are business objects, not DTO's.

Frans Bouma | Lead developer LLBLGen Pro
vairam2008
User
Posts: 86
Joined: 11-Mar-2008
# Posted on: 18-Mar-2008 18:28:23   

Isn't entities really representation of schema & avoid adding any business specific code since an entity could be used differently in 2 business scenarios. I have many scenarios where I don't need all of the columns in an entity.

I see 3 approaches using Gen Pro.

1.To inherit the entity object & define the functionality in each of the inherited object. 2.To use IValidator & create Validators for each business requirement & pass that as an argument while creating my entity. 3.To create each business object as projection object.

I am looking to see if there is a template & code generating option where I can make this method as a template with any visual or manual way of passing values to construct those objects, reducing developer coding errors.

I think this is an architecture issue as well how to do with using template. thanks

tangent
User
Posts: 41
Joined: 30-Apr-2006
# Posted on: 19-Mar-2008 20:52:46   

vairam2008 wrote:

Isn't entities really representation of schema & avoid adding any business specific code since an entity could be used differently in 2 business scenarios. I have many scenarios where I don't need all of the columns in an entity.

I see 3 approaches using Gen Pro.

1.To inherit the entity object & define the functionality in each of the inherited object. 2.To use IValidator & create Validators for each business requirement & pass that as an argument while creating my entity. 3.To create each business object as projection object.

I am looking to see if there is a template & code generating option where I can make this method as a template with any visual or manual way of passing values to construct those objects, reducing developer coding errors.

I think this is an architecture issue as well how to do with using template. thanks

Using Adapter -> 2 classes template set is an easy way to do approach number 1.

Then you can customize derivedEntityAdapter.template and entityUsingDerivedAdapter.template to control what is generated in each of the classes, that is how I do it.

vairam2008
User
Posts: 86
Joined: 11-Mar-2008
# Posted on: 21-Mar-2008 05:05:21   

will give a look into it. Thanks

vairam2008
User
Posts: 86
Joined: 11-Mar-2008
# Posted on: 28-Mar-2008 23:29:02   

Templates are described in detail in the SDK, which is available to customers. Though I don't think you really need business objects, the entities are business objects, not DTO's.

If I have to write these 2 types of validation code where would i write it if I am going to use the generated objects as my business objects.

1.if i need to do a validation when the value is set (i.e. using binding when the keyboardlostfocus happens & binding causes to set) 2.if i want to validate when I am ending edit on the current entity(i.e losing focus of row in visual & causing a validate method) - atleast I would call a validate method in this case i guess?

Using Adapter -> 2 classes template set is an easy way to do approach number 1.

Then you can customize derivedEntityAdapter.template and entityUsingDerivedAdapter.template to control what is generated in each of the classes, that is how I do it.

I don't see the additional partial class object getting created. or a derived class getting created when those templates are checked. I am trying to find out how should I do.

Also, how to use a validator & when does the methods in the validators called by the entity, is it by setvalue?

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 29-Mar-2008 19:15:22   

I don't see the additional partial class object getting created. or a derived class getting created when those templates are checked. I am trying to find out how should I do.

Just to be sure, try generating to an empty folder.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 30-Mar-2008 12:22:29   

Validators aren't generated by default. If you look at the tasks in the preset chosen at tab 3 of the code generation configuration dialog, you'll see that these tasks are disabled. If you enable them, you'll get auto-generated classes.

In general it's not that useful to generate these classes as more often people use validator classes just for a subset of the entities and use their own written classes deriving from ValidatorBase directly.

Frans Bouma | Lead developer LLBLGen Pro