Hi all, I've been scanning the web (many dozens of articles) trying to
figure out how to map a Guid (in db, representing an AddressType enum
value in code) to a type safe enum. Not a common C# enum, but rather
the custom type that follows this simple model:

public class AddressType
{

    ...(id and displayName properties)

    private AddressType(Guid id, string displayName)
    {
         this.id = id;
         this.displayName = displayName;
    }

    public AddressType InvoiceAddress = new AddressType(new
Guid("131313-244212-245245"), "Invoicing address")
    public AddressType VisitingAddress = new AddressType(new
Guid("356356-36346-5764855"), "Visitingaddress")

}



Then I have an Address class, mapped to a table that in the database
holds the Guid (foreign key) for the AddressType, but obviously I want
it to hold an instance of AddressType in code instead:

public class Address
{
    public string Street{get;set;}
    public AddressType Type{get;set;}

}



But how can this be solved by Fluent?? I have implemented an IUserType
as suggested half way down on this article:

http://jagregory.com/writings/fluent-nhibernate-auto-mapping-type-conventions/


But Fluent has been completely rewritten after the article was
published, so I cannot implement the suggested ITypeConvention, and
the code below has also been deprecated, as there is no
"WithConvention" method on the Automappings any more.

autoMappings
  .WithConvention(convention =>
  {
    convention.AddTypeConvention(new AddressTypeConvention());

Please, If someone knows how to map a property to use custom /type-
safe enums, let me know, We're getting really desperate by now!

/Ale






-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to