I think I figured it out.

I had:
public class Contact : IEntityWithTypeId<Guid>
{
    ...
    public virtual Url PictureUrl { get; set; } // DB column has the
same name
    ...
}

But I'm supposed to have:
public virtual Uri PictureUrl (not Url PictureUrl). If I understand
correctly, the Url : IUserType is not supposed to be used as the
object type in my Contact class. It's only meant to tell NH how to map
Uri to a string in the DB. I'll rename my classes accordingly.


On Jul 21, 4:05 pm, Chris Fazeli <[email protected]> wrote:
> Hi,
>
> I am trying to use Jakob Andersen's URI custom UserType in my
> application:http://intellect.dk/post/Implementing-custom-types-in-nHibernate.aspx
>
> I have read these two 
> posts:http://wiki.fluentnhibernate.org/show/AutoMappingTypeConventionshttp://groups.google.com/group/fluent-nhibernate/browse_thread/thread...
>
> Yet, I cannot get this to work. I don't need the Url to map to a
> specific column in a specific table. I just want the Automapper to
> decipher all Url types to Db.String type whenever it sees property
> names that match in the model and DB table. According to the Wiki
> pages, I shouldn't even have to override the UserTypeConvention<Url>?
> I did just for completeness.
>
> I have:
> namespace MyProject.Core.CustomTypes { public class Url :
> IUserType ... }
>
> namespace MyProject.Data.NHibernateMaps.Conventions
> {
>     public class UrlTypeConvention : UserTypeConvention<Url>
>     {
>         public override void Apply(IProperty target)
>         {
>             base.Apply(target);
>         }
>     }
>
> }
>
> private Action<IConventionFinder> GetConventions()
> {
>     return c =>
>     {
>         c.Add<PrimaryKeyConvention>();
>         ...
>         c.Add<UrlTypeConvention>();
>     };
>
> }
>
> public class Contact : IEntityWithTypeId<Guid>
> {
>     ...
>     public virtual Url PictureUrl { get; set; } // DB column has the
> same name
>     ...
>
> }
>
> But everytime I run my test to confirm the DB matches the mappings,
> the tests fail to run because the project can't initialize, with the
> error:
> An association from the table Contacts refers to an unmapped class:
> MyProject.Core.CustomTypes.Url
>
> I can fix this by creating a mapping override for my Contact entity,
> but this seems cumbersome.
>
> Any ideas what I'm doing wrong?
>
> Cheers,
> - Chris
--~--~---------~--~----~------------~-------~--~----~
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