Creating Customer Properties

Posts   
 
    
jmeckley
User
Posts: 403
Joined: 05-Jul-2006
# Posted on: 05-Jul-2006 16:23:27   

I am currently evaluating v2.0 of llblgen pro. I have downloaded the demo and tinkered with the norhwind db.

So far i am very impressed with this product. Simple business objects are easy enough to define. i am still researching validation and custom properties.

Here is a scenerio I will encounter in my project and i was woundering how would llblgen pro solve this issue. I have an entity with some simple properties. I would like to create a readonly property that would concatinate existing properties to create consistant descriptors for on screen display/reporting.


WidgetEntity
{
  int size 
  string shape 
  string color 

  string readonly descriptor
 {
   get { return string.concat( this.size.toString(), " inch ", this.color, " ", this.shape); }
 }
...
}

This would be a simple descriptor. Some may be more complex involving if statements to account for null values.

Is this code something i would need to enter by hand after the code is generated? or will the OR GUI allow me construct these properties?

If I must write them by hand I would perfer to keep them in the same file (not seperate file using partial class) to simplify the file structure. Is there a place within each entity to allow this so the custom properity will not be overwritten when the objects are recreated?

With the above method could I access the property directly

 WidgetEntity widget = new WidgetEntity();
widget.descriptor;

or would I need to go through a Dictionary? (I haven't knowingly worked with a dictionary before).

thank you for your assistance in my evaluation process.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 06-Jul-2006 04:43:07   

Is this code something i would need to enter by hand after the code is generated? or will the OR GUI allow me construct these properties?

You can enter them by hand after the code is generated.

If I must write them by hand I would perfer to keep them in the same file (not seperate file using partial class) to simplify the file structure. Is there a place within each entity to allow this so the custom properity will not be overwritten when the objects are recreated?

Check the manual under "Generated code - Adding your own code to the generated classes". It explains Defined user code regions which can be used to write code that is kept after generation.

Posts: 1263
Joined: 10-Mar-2006
# Posted on: 06-Jul-2006 05:38:00   

Jason, Yes, you can do this and it is very easy. Just locate the Entity you are interested in, scroll down to the bottom and you will find a section marked "__LLBLGENPRO_USER_CODE_REGION_START" in a Custom Entity Code region.

Add properties or anything you want in that region and it will be preserved.