From: Fabio M. (JIRA) <nh...@gm...> - 2011-04-10 23:13:59
|
[ http://216.121.112.228/browse/NH-2637?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Fabio Maulo closed NH-2637. --------------------------- Resolution: Not an Issue It is by design because properties and fields are case-sensitive in .NET and if you have a property called "FirstName" with a field called "firstName" the default transformer have to know to which one it have to access. You can specify the alias in your query or you can implement your AliasToEntityResultTransformer. > NHibernate.Properties.BasicPropertyAccessor.GetSetterOrNull is case sensitive > ----------------------------------------------------------------------------- > > Key: NH-2637 > URL: http://216.121.112.228/browse/NH-2637 > Project: NHibernate > Issue Type: Bug > Components: Core > Affects Versions: 3.1.0 > Reporter: Igor Krupin > Priority: Major > Attachments: Capture.PNG > > > We are running NH 2.1 and discovered this bug trying to upgrade to NH 3.1. We do a lot of AliasToBean stuff, mapping tables to DTOs, and AliasToBean will call this method to get the properties. Problem is, it's case sensitive now! Reading code comments i see this: > ============ <CODE SNIPPET> ================ > BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly; > if (type.IsValueType) > { > // the BindingFlags.IgnoreCase is important here because if type is a struct, the GetProperty method does > // not ignore case by default. If type is a class, it _does_ ignore case... we're better off explicitly > // stating that casing should be ignored so we get the same behavior for both structs and classes > bindingFlags = bindingFlags | BindingFlags.IgnoreCase; > } > ============ </CODE SNIPPET> ================ > "If type is a class, it _does_ ignore case..." -- incorrect. By default in classes case will _not_ be ignored, you explicitly have to specify it using a flag, same as you do for value type. > The fix for this is rather simple, just add the BindingFlags.IgnoreCase flag and all's good. No need for the "if (type.IsValueType)" anymore either. GetGetterOrNull suffers from the same. > Thank You!!! > Igor -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://216.121.112.228/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |