Dmitry
Dmitry

Reputation: 53

Nhibernate linq fetch in subclass

Help me, please, solve one problem.

I have project, which uses Nhibernate and Fluent Nhibernate. There I created one base class (it is not real classes, but they describe my situation):

public class Document
{
    public virtual int Id { get; private set; }
    public virtual Account Acc { get; private set; }
}

And mapping for it:

public class DocumentMap: ProfileEntityMap<Document>
{
    public DocumentMap()
    {
        Id(m => m.Id);
        References(m => m.Acc);
        DiscriminateSubClassesOnColumn("Type");
    }
}

Then I implemented subclass:

public class PaymentDocument: Document
{
    public virtual Card AccountCard { get; set;}
}

Mapping for class PaymentDocument:

public class PaymentDocumentMap : SubclassMap<PaymentDocument>
{
    public PaymentDocumentMap()
    {
        References(t => t.AccountCard);
    }
}

And after that I try execute this query:

payments = session.Query<PaymentDocument>()
    .Fetch(t => t.Acc)
    .Fetch(t => t.AccountCard)
    .ToList();

And when I insert first fetch I get next exception:

Object reference not set to an instance of an object.

Can somebody answer me where is a problem?

Upvotes: 4

Views: 910

Answers (1)

ovolko
ovolko

Reputation: 2807

Actually it was a bug fixed in 3.0.0.Alpha2. Right now it works with the trunk.

Upvotes: 2

Related Questions