sapiens/SqlFu

Columns with an underscore character values are not being mapped correctly

Closed this issue · 1 comments

I have an existing Table in SQL Server that I am attempting to use the Get method of SqlFuConnection to retrieve the value for. In this instance the value at the database is a decimal and the value can be anything that is positive or negative. When I issue the call:

var obj = db.Get(o => o.Id == id); the property is set to 0 for the column that contains an underscore character.

obj.My_Property => 0

If I instead return a dynamic object, then the correct value is returned. For example: var dynobj = db.get( "select * from table where Id =@0", id);

dynobj.My_Property => -1

Any thoughts on this?

Thanks.

Yeah, it's because the underscore signals multi poco mapping. A quick workaround, if you don't care about multi poco mapping (and want to keep using those property names) is to change the mapping convention from '_' to other stuff like '.'

PocoFactory.ComplexTypeMapper.Separator = '.'