tmsmith / Dapper-Extensions

Dapper Extensions is a small library that complements Dapper by adding basic CRUD operations (Get, Insert, Update, Delete) for your POCOs. For more advanced querying scenarios, Dapper Extensions provides a predicate system. The goal of this library is to keep your POCOs pure by not requiring any attributes or base class inheritance.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AutoMap doesn't work for Id column anymore...?

k3davis opened this issue · comments

I was surprised and happy today to notice this library had received some updates. There was a breaking change with Predicate namespaces but nothing else was immediately noticeable (I was using an unofficial netstandard build of 1.6.3 previously).

With the update I had to make changes to the mapping for classes that have an Id column.

public AcctDataMapper()
{
    Table("Acct_Data");
    Map(x => x.Id).Column("Id"); // AutoMap() used to do this but it doesn't work anymore
    Map(x => x.BankName).Ignore();
    Map(x => x.LinkedProfiles).Ignore();
    Map(x => x.LinkedActiveProfiles).Ignore();
    Map(x => x.Status).Ignore();
    AutoMap();
}

I couldn't locate any substantial release notes (maybe I missed them) so perhaps this is already explained somewhere. There are much more elaborate failures than this but this is a more concise example. What change did I miss...?

Could you send me a more complete example of the problem because AutoMap uses Id as default "Key" for the classes if no Key was defined.

If you look in this test POCO class you'll see that it's using AutoMap.

What I notice in you map is that you actually mapped Id manually and didn't assign any key to it. In this case you're saying to your map that Id is "NotAKey"

I added that line to my map in response to the automap no longer working, as the comment says. Nevertheless i'm not using this library anymore and this issue is rightfully closed. Thanks.