zzzprojects / Dapper-Plus

Dapper Plus - High-Efficient Bulk Actions (Insert, Update, Delete, and Merge) for .NET
https://dapper-plus.net/
383 stars 85 forks source link

Mapping does not work when querying data #68

Open ElenaShlykova opened 4 years ago

ElenaShlykova commented 4 years ago

I have such mapping:

DapperPlusManager.Entity<TestEntity>()
               .Key(x => x.Id, "ID")
               .Map(x => x.Name, "TestName")
               .Output(x => x.Id)
               .Table(TableName);

When I save data with BulkInsert it works, but when I query data the "Name" property is empty.

   public class TestEntity
   {
      public int Id { get; set; }

      public string Name { get; set; }
   }

         using (var connection = SessionFactory.OpenConnection())
         {
            return connection.Query<T>("select * from TestEntity").ToList();
         }

Is there a way to get this to work correctly?

JonathanMagnan commented 4 years ago

Hello @ElenaShlykova ,

The mapping currently only works for method coming from Dapper Plus such as BulkInsert, BulkUpdate, BulkDelete, BulkMerge.

Query method is from Dapper itself so we do not have any control over it.

However, we will look if there is something we can do here this week such as providing additional helper/method if the Query is coming from the DapperPlusContext.

JonathanMagnan commented 4 years ago

Hello @ElenaShlykova ,

This is eventually something we will want to do in the future.

Unfortunately, we choose to pause temporarily this request as we need to complete the code re-write of our primary library for EF Core 5 which is coming.

We will let this issue open since as we said, that's definitely something we will want to add to our library