brucezhang80 / dapper-dot-net

Automatically exported from code.google.com/p/dapper-dot-net
Other
0 stars 0 forks source link

Property matching on POCO's is case sensitive #7

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In rev. 2f73f171cfdf Dapper expects database column names to match property 
names exactly. When you have a database naming convention that uses lower case 
first letters while the objects adhere to the C# naming conventions (i.e. 
upper-case first letters), the properties are never set.

Solution:

Either document the case sensitivity or enable case insensitive property 
matching.

For the latter option a single change on line 419 is all it takes:              

select new { Name = n, Info = properties.FirstOrDefault(p => p.Name.Equals( n, 
StringComparison.OrdinalIgnoreCase ) ) }
                          ).ToList();

Original issue reported on code.google.com by marnixva...@gmail.com on 19 Apr 2011 at 12:39

GoogleCodeExporter commented 9 years ago
I've changed it to use a case-sensitive check *first*, falling back to 
case-insensitive if no case-sensitive match is found

Original comment by marc.gravell on 22 Apr 2011 at 12:11