简体   繁体   中英

Fluent NHibernate Mapping

I have the class filter.cs with this attributes:

    public virtual int Id { get; set; }
    public virtual Attribute Attribute { get; set; }
    public virtual Int16 Type { get; set; }
    public virtual string FilterValue { get; set; }
    public virtual ReportConfiguration ReportConfiguration { get; set; }

Attribute and ReportConfiguration are a Foreign Key.

I made this mapping:

        Id(a => a.Id).UnsavedValue(0).GeneratedBy.Identity();
        Map(a => a.Type);
        Map(a => a.FilterValue);
        References(x => x.ReportConfiguration).Column("IdReportConfiguration").Not.LazyLoad();
        References(x => x.Attribute).Column("IdAttribute").Not.LazyLoad();

In addition, I have a Repository class for example with the method:

public int Create(Filter F)
    {
        int FilterId = 0;
        Transactional(session =>
        {
            FilterId = (int)session.Save(F);
        });
        return FilterId;
    }

And when I did the Unit Test of Create(Filter F) it produced an exception:

No persister for: ....Filter.cs

I think the mapping is not correct.

Any idea?

Thanks and best regards.

Try here:

Fluent Nhibernate No persister for:

From the above post:

Solution: This error occurs since the class is not public. Just change the class to public and this won't occur again. However, if you do not want to expose the assembly outside the Assembly you can still mark the constructor as 'internal'.

Is this your situation?


This is a similar question:

Fluent Nhibernate No Persistor for Class Name

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM