0

Hi a have following inheritance :

class A {

 } class B : A {

 } 
class C { 
    public A Product{get;set} 
}

and fluent mapping where i map C like :

References(x => x.Product).Cascade.SaveUpdate();

when i try to convert Product to B a get cast exception because nhibernate return a proxy of type A , i tried to set up lazy load no proxy for that property but it didn't work : References(x => x.Product).LazyLoad(Laziness.NoProxy).Cascade.SaveUpdate(); how can i fix it ? Thanks in advance

1 Answer 1

1

3 Options:

1) disable LazyLoading for this reference

2) ReferenceAny: stores the type of A in Table of C

3) Use Polymorphism instead of casting

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.