I've run into a strange error in fluent nhibernate. I have a basic set of classes that inherit from interfaces, and I have mapped the interfaces to tables, and where classes utilize these, they implement a generic of the interface. They are defined as follows;
interface IPage {
// properties
}
class IPageMap : ClassMap<IPage> {
// mapping information
}
class Page : IPage {
// IPage Implementation
}
class ITag {
// properties
}
class ITagMap : ClassMap<ITag> {
// mapping information
}
class Tag : ITag {
// ITag implementation
}
class Template {
virtual IList<IPage> Pages { get; set; }
virtual IList<ITag> Tags { get; set; }
}
This should work fine. When I create an object like this ...
var pages = new List<IPage> {
new Page {
// ..
}
}
pages.ForEach( x => { session.SaveOrUpdate(x); } ); // no exception here
var tags = new List<ITag> {
new Tag {
// ...
}
}
tags.ForEach( x => { session.SaveOrUpdate(x); } ); // exception happens here.
var list = new List<Template> {
new Template {
Pages = new List<IPage> {
new Page {
// ...
}
},
Tags = new List<ITag> {
new Tag {
// ..
}
}
}
}
I am given the following exception.
There is no persister for
Tag
Okay, I didn't define a persister for Tag, but I did for ITag, and Tag inherits it. IPage and Page work the same way. If I comment out the tag information and just leave the IPage and Page implementation, it works fine for those.
Why is ITag and Tag being treated differently? Any ideas?