Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

Rainbow table doesn't support IDs of type long

Open Khaos66 opened this issue 2 years ago • 1 comments

We have a legacy db with very long Ids. Example: 301000000003

So the POCO looks like this:

public class User
{
    public long Id { get; set; }
    // ...
}

And the database class like this:

public class LegacyDatabase : Database<LegacyDatabase>
{
    public Table<User, long> Users { get; set; }
    // ...
}

When calling InsertAsync however there is an exception thrown. This is because of the fixed return type of int? for InsertAsync. See: Database.Async.cs#L19

Is this by design? Shouldn't the generic type TId be used here?

Khaos66 avatar May 12 '22 06:05 Khaos66

As a workaround I created a subclass of Table and copied InsertAsync with a return type of long?. Sadly the database property of the Table class is marked as internal. So i needed an additional field for that, too. And also the methode GetParamNames is marked as internal. So i needed to copy that one, too... All in all, it's working but not a very good solution =/

Khaos66 avatar May 12 '22 06:05 Khaos66