Automap custom value object (ICompositeUserType)

Jacob's Avatar

Jacob

28 Oct, 2010 06:17 AM via web

Hi there,

The Accept method is never called for the property type of MyValueObject, so I'm not able to apply CustomType(typeof(MyValueObjectCompositeUserType)) in the Apply method of the convention.
I have tryed to remove the IsComponent override method in the AutomappingConfiguration, but this result in an exception, since MyValueObject have no Id property (make perfect sense).

I have tryed to implement a IComponentConvention convention, but here its not possible to apply the custom type.

Any idea of what I'm missing here?

I have the following setup of conventions (simplified):

public class AutomappingConfiguration : DefaultAutomappingConfiguration
{

public override bool ShouldMap(Type type)
{
     return type == typeof (MyEntity) || type == typeof (MyValueObject);
}

public override bool IsComponent(Type type)
{
    return type == typeof(MyValueObject);
}

}

public class EnumerationConvention : IPropertyConvention, IPropertyConventionAcceptance
{

public void Apply(IPropertyInstance instance)
{
    instance.CustomType(typeof(MyValueObjectCompositeUserType));
}

public void Accept(IAcceptanceCriteria<IPropertyInspector> criteria)
{
    criteria.Expect(x => x.Type == typeof (MyValueObjectCompositeUserType));
}

}

This is my model:

public class MyEntity
{

public int Id { get; set; }
public MyValueObject MyValue { get; set; }

}

public class MyValueObject
{

public int SomeValue1 { get; set; }
public int SomeValue2 { get; set; }

}

    Reply to this discussion

    Preview Comments are parsed with Markdown. Help with syntax

    Attached Files

      You can attach files up to 10MB

      What is 4 times four?