Hello there!
Please consider the following simple scenario:
public class Foo
{
public virtual int Id
{
get;
private set;
}
public virtual IBar Bar
{
get;
set;
}
}
public interface IBar
{
string Text
{
get;
set;
}
}
public class Bar : IBar
{
public virtual string Text
{
get;
set;
}
}
public class FooMap : ClassMap<Foo>
{
public FooMap()
{
Id(x => x.Id);
Component(x => x.Bar, m =>
{
m.Map(x => x.Text);
});
}
}
While running any query agains this configuration, I get the following
exception:
NHibernate.InstantiationException "Cannot instantiate abstract class
or interface: NHMappingTest.IBar"
As far as I understand, NHibernate tries to instantiate an IBar object
instead of the Bar concrete class (Of course, when I change the type
of the property Foo.Bar from IBar to Bar, everything works well).
My question is how to let F-NH know which concrete class to
instantiate? Discarding the type inference by wiring explicitly Bar
("Component<Bar>") does not work neither (same error).
>From what I have seen in the source code
(FluentNHibernate.Mapping.ClasslikeMapBase) F-NH infers the type
directly from the lambda expression (x => x.Bar) and not from the
generic type passed to Component.
Any suggestion, workaround, or solution?
Thanks a lot in advance.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---