I have an existing NHibernate application that was created in .NET 2, it’s a WinForms app that has a separate DLL compiled for the data classes & all the hbm.xml files.
What I want to do now is show on the form which fields are not nullable, by changing the border to red.
Problem is I can’t seem to find anywhere where I can cycle through the bound fields (that I can do) on the form, and read the not-null=”false” (or true) parameter.
Any thoughts?
I am open to Fluent NHibernate, however this is a VB.NET app, and I am a Fluent Nhibernate noob 🙂
Also open to other ways of doing this, as long as I can make them fit into the app reasonably well 🙂
Thanks!
You don’t need to read the hbm.XML files directory as the
SessionFactorycontainsMetaDataregarding all mapped entities. One way to find all meta data for a entity is as follows;After the SessionFactory has been built:-
In my case I get the following:-
Remember FALSE means NOT-NULL that is the property expects an entry
Another way is to add
DataAnnotationsto your model properties.There are good articles on the internet to show you how to use this in a winforms project.