adamfoneil / Dapper.CX

A Crud library based on Dapper
MIT License
8 stars 1 forks source link

using [Column] attribute without Name leads to null ref exception #18

Closed adamfoneil closed 4 years ago

adamfoneil commented 4 years ago

This came up in AH where I was using EF migration with model class. EF requires an Order property on composite primary keys for some reason. So I added this, but then Dapper.CX assumes that if you have a Column attribute it's because you're going to override the column name. If you don't provide a name, then you get null ref. Issue is here. Pretty sure this should be written as

if (attr != null) result = attr.Name;
return result ?? propertyInfo.Name;