I'm new to dealing with NHibernate, and I try to use this existing code; I hope someone can help out.
I now realize that this question might relate to "Fluent NHibernate".
What should I do with a field that is a computed column in SQL Server? I just need NHibernate to read it up, and I don't want NHibernate to touch it at all when calling PerformSaveOrUpdate.
It's mapped in this filemap:
Map(x => x.Path).ColumnNames.Add("fil_path").Not.Nullable();
I've tried Not.Nullable and Nullable, and no "addition" at all ... but any way there is an error trying to save, either because the field is nullable and the database won't allow data to be saved to this computed field:
The column "fil_path" cannot be modified because it is either a computed column or is the result of a UNION operator.
... or when set to not nullable, I get this: not-null property references a null or transient value [...].Model.Entities.File.Path
In the "File" entity class of the same project, the Path property looks like this: public virtual string Path { get; private set; } // Calculated by customer specific formula. Which seems to be ok... since it should never be assigned by the user.
How do I tell NHibernate and / or "PerformSaveOrUpdate" not to update this specific field?
Edit: I ended up setting the mapping to ReadOnly, this way: Map(x => x.Path).ColumnNames.Add("fil_path").ReadOnly(); End Edit
Thanks, Andreas Jansson
|