Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > Designer> Mapping fields to enums
 

Pages: 1
Designer
Mapping fields to enums
Page:1/1 

  Print all messages in this thread  
Poster Message
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
65 posts
# Posted on: 21-Apr-2009 20:18:02.  
I'm surprised llblgen doesn't do this, so I want to make sure I'm not missing something.

Every time I start a new project with llblgen I end up with a lot of database columns that store integers, but in my generated objects I want these to be mapped to enums. So I have
to go through and shadow/override the properties to treat them as enums. It would be nice if I could specify the enum name in the designer and have the properties generated based on this.
  Top
MTrinder
User



Location:
London by day, Milton Keynes by night.
Joined on:
08-Oct-2008 17:55:47
Posted:
1461 posts
# Posted on: 21-Apr-2009 21:35:48.  
Take a look at these two threads. I believe they cover exactly what you are doing.
http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7355
http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=7378


  Top
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
65 posts
# Posted on: 22-Apr-2009 16:07:44.  
Thanks for those examples. They might be helpful in some cases, but in my current project I have 100 or more enums in use, so I don't want to have to code a type converter for all of them--at that point it would be easier to override the properties in the generated code. What I'm envisioning is a checkbox in the designer to indicate that the field is an enum, and a box to enter the enum name.
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14484 posts
# Posted on: 22-Apr-2009 16:22:41.  
Otis wrote:
Re-hasing myself perhaps: enum creation inside the designer requires data reading by the designer. We don't do that and it's very likely it will never be done: the designer reads meta-data not real data. Not only that, if the schema is empty or new, there is no data.

ref: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=13612


  Top
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
65 posts
# Posted on: 22-Apr-2009 16:36:47.  
I'm not talking about having llblgen generate the enumeration definitions for me based on the database, just changing the type that gets generated for a field.

To clarify: In the database I have an integer field named, for example, "Options". Somewhere in my code I have an enumeration that defines the values that are allowed for the "Options" field for this entity:

Code:
enum MyOptionsEnum
SomeOption=1,
SomeOtherOption=2,
AThirdOption=3
end enum


After llblgen generates my class, with Options as an integer, I override that property so that Options is now a MyOptionsEnum instead of an integer:

Code:

public shadows property Options as MyOptionsEnum
Get
     return ctype(mybase.Options,MyOptionsEnum)
End Get
Set (value as MyOptionsEnum)
     mybase.Options=ctype(value,int)
End Set
end property


What would be nice is if, int the designer, I could specify that the "Options" field is a "MyOptionsEnum" enumeration. llblgen would then generate the property as MyOptionsEnum instead of integer.
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14484 posts
# Posted on: 22-Apr-2009 17:38:44.  
And then the generated code wouldn't compile unless you reference your BL or the code where the enum is defined.

Or do you want LLBLGen to define an empty enum for you in the generated code, and later on you'd manually define enum elements/values.

Personally I think TypeConverters are the best option here.


  Top
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
65 posts
# Posted on: 24-Apr-2009 19:14:30.  
Yes, I then add a file to the generated project to define the enums. I don't want llblgen to do anything other than set the field's type to MyOptionsEnum instead of int.

As I said, if I have to code a type converter for every one of the 100 enums used in the project, even if it's just a line of code to use a templated converter class, that's nearly as much work as just overriding the properties to handle the enums that way. It adds one more step to the process, and is one more piece to maintain.
  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8071 posts
# Posted on: 27-Apr-2009 05:31:28.  
You could use custom properties on the involved fields to point the enum class name. Then you could modify a little bit the templates to read this value and generate your appropiate code (See ASP.NET 2.0 GUI Templates to get an idea). I dont know whether this would be worthy. As Walaa I would recommend TypeConverters as they are more maintainable that templates, IMHO, as you have 100% control over your TypeConverters. With LLBLGen Templates you will have to update your code in every templates release you update. Even if you have 100 typeConverters, you onle have to write them once Regular Smiley

Anyway please let us know your decision and/or whether you need further help on this.


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.