I have a domain class that looks like this. I want NHibernate to keep the current LastUpdate value on insert / update, so that I can use it in queries, but ignore it when retrieving Foo from the database and let the object itself recount the value when I actually access it.
public class Foo { public DateTime LastUpdate { get { return value; } } public IEnumerable<History> History { get; set; } }
My mapping for Foo looks like this:
public class FooMap : ClassMap<Foo> { Map(x => x.LastUpdate) .ReadOnly(); HasMany(x => x.History);
I thought that ReadOnly() is what I wanted to execute, but when I try to create a SessionFactory, I get the following exception:
Error: FluentNHibernate.Cfg.FluentConfigurationException: An invalid or incomplete configuration was used when creating the SessionFactory. See the PotentialReasons and InnerException collection for more information.
---> NHibernate.PropertyNotFoundException: Could not find setter for property "LastUpdate" in class "Foo".
The property does not have a setter, because it should not be set, only read. Is ReadOnly() right thing here? If not, what?
(NHibernate v3.0b1, Fluent NHibernate v1.1)
source share