Defining Enums

Posts   
1  /  2
 
    
nw
User
Posts: 42
Joined: 09-Jun-2010
# Posted on: 29-Jun-2010 06:48:03   

Are there any examples, for defining Enums so that I can assign them to fields? So far the closest thing I have found is in here http://www.llblgen.com/documentation/3.0/Designer/Functionality%20Reference/EnumTypeImports.htm

I have defined the location of the .typeimports file in the Designer using the AdditionalTypeConverter property and have also defined the enum in an assembly.


<typeImports>
    <typeImport typeName="TestEnum" assemblyFile="TypeLibrary.dll"/> 
</typeImports>

namespace TypeLibrary
{
    public enum TestEnum
    {
        No,
        Yes
    }
}

However, when I reload the llblgen project file, and tried going to Field mappings for an entity, I cannot choose the Type Converter to use.

What am I missing or doing incorrectly?

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 29-Jun-2010 07:38:46   

Does the field have the same type as defined in the TypeConverter?

nw
User
Posts: 42
Joined: 09-Jun-2010
# Posted on: 29-Jun-2010 08:24:58   

Walaa wrote:

Does the field have the same type as defined in the TypeConverter?

How do you define the type? I can define the type in the .Net type column.

nw
User
Posts: 42
Joined: 09-Jun-2010
# Posted on: 29-Jun-2010 08:28:14   

Where do you set the type?

nw
User
Posts: 42
Joined: 09-Jun-2010
# Posted on: 29-Jun-2010 08:31:00   

Walaa wrote:

Does the field have the same type as defined in the TypeConverter?

Do you have to define a Type Converter? According to the documentation "...As all target frameworks support enum types directly, you don't need type converters to work with enum types"

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 29-Jun-2010 09:27:01   

You don't need a typeconverter for enums in v3.

There are a couple of things to check: - where did you store the dll with the enum? - when you right-click the project node in project explorer and select 'edit type shortcuts' can you define a shortcut for the enum type?

Frans Bouma | Lead developer LLBLGen Pro
nw
User
Posts: 42
Joined: 09-Jun-2010
# Posted on: 29-Jun-2010 10:21:28   

Otis wrote:

You don't need a typeconverter for enums in v3.

There are a couple of things to check: - where did you store the dll with the enum? - when you right-click the project node in project explorer and select 'edit type shortcuts' can you define a shortcut for the enum type?

1) I mocked up a console app and so the dll with the enum is in bin\debug folder which is the exact same path as defined for AdditionalTypeConverterFolder in Designer Behaviour. I have also hard coded the full path in the typeImports file.

2) Nope. The enum is not there.

Anything I need to do to "compile" the enum? I am guessing only a restart of the LLBLGen is required.

nw
User
Posts: 42
Joined: 09-Jun-2010
# Posted on: 29-Jun-2010 10:37:20   

Attached is a sample console app that I have created.

1) VS solution in llblgen\AxProjConsoleApp\ConsoleApp folder (ConsoleApp.sln) 2) LLBLGen project in llblgen folder (AxProj.llblgenproj) 3) DDL script in llblgen folder (DDLSQL_CreateScript_20100629-092215.sql)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 29-Jun-2010 21:51:53   

It looks like you use .NET 4. You compiled the enum assembly as .net 4 assembly? Because that won't work as the designer runs on the .NET 2.0 (.NET 3.5) clr. If you want to run the designer on the .NET 4 clr, please open llblgenpro.exe.config in a text editor and uncomment the commented out xml lines as described in comments in that file.

Frans Bouma | Lead developer LLBLGen Pro
nw
User
Posts: 42
Joined: 09-Jun-2010
# Posted on: 30-Jun-2010 03:06:55   

Otis wrote:

It looks like you use .NET 4. You compiled the enum assembly as .net 4 assembly? Because that won't work as the designer runs on the .NET 2.0 (.NET 3.5) clr. If you want to run the designer on the .NET 4 clr, please open llblgenpro.exe.config in a text editor and uncomment the commented out xml lines as described in comments in that file.

I uncommented the following:


<supportedRuntime version="v4.0.30319"/>

<legacyCasPolicy enabled="true" />

And it is still not working. Anything else that I missed?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Jun-2010 06:18:40   

I think I got it simple_smile The typeName must be the full class name. So please use this:

<typeImports>
    <typeImport typeName="TypeLibrary.TestEnum" assemblyFile=".......\TypeLibrary.dll"/> 
</typeImports>

... and to be able to use your type in entity editor, add a Type Shortcut Definition for it.

David Elizondo | LLBLGen Support Team
nw
User
Posts: 42
Joined: 09-Jun-2010
# Posted on: 30-Jun-2010 08:04:26   

daelmo wrote:

I think I got it simple_smile The typeName must be the full class name. So please use this:

<typeImports>
    <typeImport typeName="TypeLibrary.TestEnum" assemblyFile=".......\TypeLibrary.dll"/> 
</typeImports>

... and to be able to use your type in entity editor, add a Type Shortcut Definition for it.

Works! Thank you!

nbrake
User
Posts: 30
Joined: 18-May-2008
# Posted on: 24-Feb-2011 14:19:09   

Hi there,

my problem is similar so I opted for keeping the thread!

I have defined an Enum:


namespace Wk.ImportTypes
{
    public enum Status : byte
    {
        NichtBearbeitet,
        Bestaetigt,
        Veraendert
    }
}

and an importtypes file:


<typeImports>
    <typeImport typeName="Wk.ImportTypes.BearbeitungsStatus" assemblyFile="Wk.ImportTypes.dll"/> 
</typeImports>

Right-clicking on project, I can define the type in the Type Short Cut editor. I called the short cut Status.

I have a table with columns defined as tinyint. There columns are mapped to c# byte. When I edit the field mappings in entity editor, I am unable to choose the Status type for mapped fields of type byte.

Would really appreciate any help on this!

Best regards

Nasser

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 24-Feb-2011 20:50:35   

my problem is similar so I opted for keeping the thread!

Please start new threads as it makes it easier for us to track current topics.

Can you select your status for any other column types ?

Matt

nbrake
User
Posts: 30
Joined: 18-May-2008
# Posted on: 24-Feb-2011 20:52:34   

sorry for the thread issue.

I cannot choose the shortcut for any type at all.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 24-Feb-2011 20:58:21   

Which folder is your .dll (which contains the enum) located in ?

Matt

nbrake
User
Posts: 30
Joined: 18-May-2008
# Posted on: 24-Feb-2011 21:04:52   

The dll is in a folder that is given as a relative path in an .typeimports file. The dll is being read, as I am able to see the enum type in the Type Shortcut Editor. There I am able to create the Shortcut. When I go into Field mappings, and try to choose a shortcut from TypeConverter to use column, none are available.

Thanks for your help!

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 24-Feb-2011 21:17:07   

Can you attach or send us your .dll (or the code to build it) and we'll investigate.

Thanks

Matt

nbrake
User
Posts: 30
Joined: 18-May-2008
# Posted on: 24-Feb-2011 21:19:25   

The dll only consists of the enum, nothing else!

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 24-Feb-2011 21:21:42   

How do you have the shortcut defined ? (Screenshot...?)

nbrake
User
Posts: 30
Joined: 18-May-2008
# Posted on: 24-Feb-2011 21:54:06   

Here is the screenshot.

Attachments
Filename File size Added on Approval
Creating Shortcut.png 38,677 24-Feb-2011 21:54.18 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Feb-2011 06:51:15   

nbrake wrote:

Hi there,

my problem is similar so I opted for keeping the thread!

It's not the same problem as you can load your custom type.

nbrake wrote:

I have a table with columns defined as tinyint. There columns are mapped to c# byte. When I edit the field mappings in entity editor, I am unable to choose the Status type for mapped fields of type byte.

I can't reproduce your problem, with similar project (similar enum, column tyniint/byte) and I'm able to create the shortcut and assign that to the byte fields.

What LLBLGen build version are you using? Could you post an screenshot or your .llblgenproj file?

David Elizondo | LLBLGen Support Team
nbrake
User
Posts: 30
Joined: 18-May-2008
# Posted on: 25-Feb-2011 10:19:45   

I am using LLBLGen Pro 3.0 final october 22nd. Attached please find the project file.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 25-Feb-2011 10:43:39   

I am using LLBLGen Pro 3.0 final october 22nd.

That's old. To be on a common ground, could you please try with the latest release.

nbrake
User
Posts: 30
Joined: 18-May-2008
# Posted on: 25-Feb-2011 10:45:19   

I will and then get back to you.

1  /  2