开发者

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.Account开发者_运维问答Card);
    }
}

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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜