NHibernate property access strategy, How to set it up so that field.camelcase-underscore is preferred but autoproperty is fall back -


I want to set up an access strategy so that one area camelcase-underscore property backing is present, use it and others Use Automatic Property

Is this the default behavior (since auto props are basically backed up fields)? Or how to apply it?

By default the property is used to setter, so you need if you have backing field , Then specify access as camelcase underscore field (or whatever naming convention you use).

This may be an easy way to get it, but you can use Fluent NHibernate's conventions to apply this behavior if using the backing fields and otherwise when the providers If the conference is implemented, then you can reflect the type of unit to check whether there is a similar camera campaign underscore field or not. If a backing field is found, then you modify the mapping to use the camelcase underscore as access.

Here is an example using IPropertyConvention. (You may also want to do a similar investigation in one-to-many conferences):

  Public class PropertyAccessConvention: IPropertyConvention {Public Null implementation (IPProtest instance example) {type entityType = Examples. Anti-type; String camel cassondersnames = convertcomcam cssandrecore (example.Name); Bool Hatchingfield = Hasfield (Entity Type, Unicode From Name); // To use the default property setter, so only modify the mapping / if there is a backing field (ifbacking field) example. Access CamelCaseField (CamelCasePrefix.Underscore); } Private Static String ConvertTextCassandcorecore (string attribute name) {return "_" + propertyName [0]. Ostring (). ToLower () + propertyName.Substring (1); } Private Bull Hasfield (type type, string field name) {Field info backingfield = type. Gatefield (Field Name, Binding Falges: Nonpolic | BindingFlag.Instance); Return Backingfold! = Null; }}  

Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -