Enum Support

Enum Support

Postby JoeRuspante » Mon 07 May 2012 23:06

Does dotConnect support enums?
If so, what kind of enums does it support? only long or also short, string and so on?

Thank you in advance
JoeRuspante
 
Posts: 54
Joined: Mon 05 Jul 2010 23:08

Re: Enum Support

Postby Pinturiccio » Fri 11 May 2012 12:05

Support for enumerated types ("enums") in Devart LinqConnect and Devart Entity (for Entity Framework June 2011 CTP) models was implemented starting from the 6.50.214 version of dotConnect for Oracle.
So if the version of your dotConnect for Oracle is 6.50.214 or higher, you can use enum types in your Devart Entity models for Entity Framework June 2011 CTP. Besides, Entity Framework 5.0 Beta is supported since the 6.80.325 version of dotConnect for Oracle.

With Entity Developer you can add new enum types to the model and display them on the diagram, add enum type members and modify or delete existing enums.
Properties of the enum types, as well as those of their members, can be conveniently set and modified in the new Enum Type Editor.

Note that Entity Framework models support only integer enums.
Pinturiccio
Devart Team
 
Posts: 2046
Joined: Wed 02 Nov 2011 09:44

Re: Enum Support

Postby JoeRuspante » Sat 12 May 2012 09:32

Thank you in advance, but I forgot a thing...
I'm using Code First and the last version of dotConnect (downloaded yesterday).

I tried to use enums but it doesn't seems to work (the runtime gives me an exception saying that the enum type is not mapped).

For now I'm working in this way:

Code: Select all

public class MyClass
{

    public int Id { get; set; }

    ....

    public int MyProperty { get; set; }
}


public enum MyPropertyTypes : int
{
    ValueA = 1,
    ValueB = 2,
    ValueC = 3
}



....  (setter)

   MyClass a = new MyClass();
   a.MyProperty = (int)MyPropertyTypes.ValueA;

...  (test)

   var query = from a in DbContext.MyClasses
                      where a.MyProperty == (int)MyPropertyTypes.ValueA
                      select a;




Of course, I'd like to use the enum in the right way (without the cast), but I'd like to know if the enum support works good simply with a "setting" somewhere in the code (for example in the OnModelCreating of the DbContext)
JoeRuspante
 
Posts: 54
Joined: Mon 05 Jul 2010 23:08

Re: Enum Support

Postby Pinturiccio » Mon 14 May 2012 13:49

Are you sure, you are using Entity Framework 5? Regular Entity Framework 4.3.1 does not support enums.
Here is a useful tutorial about enums from Microsoft: http://msdn.microsoft.com/en-us/hh859576
Pinturiccio
Devart Team
 
Posts: 2046
Joined: Wed 02 Nov 2011 09:44

Re: Enum Support

Postby JoeRuspante » Mon 14 May 2012 15:03

Thank you in advance!
I'm using last E.F. but not the one in beta (so no 5.0).

I will wait since this EF won't be in beta (not a good idea use a beta release in production). Maybe later I will change the EF.

I thought that since devart supports enums, it would work also with an old EF reference.
JoeRuspante
 
Posts: 54
Joined: Mon 05 Jul 2010 23:08


Return to dotConnect for Oracle