vendredi 7 août 2020

Access to static readonly ConcurrentDictionary

How access to TypeTableName in Dapper.Contrib.Extensions.SqlMapperExtensions class using Reflection?

private static readonly ConcurrentDictionary<RuntimeTypeHandle, string> TypeTableName = new ConcurrentDictionary<RuntimeTypeHandle, string>();

Cannot set null to SqlMapperExtensions.TableNameMapper because use TypeTableName

https://github.com/StackExchange/Dapper/blob/main/Dapper.Contrib/SqlMapperExtensions.cs#L280

Delegate[] delegados  = Dapper.Contrib.Extensions.SqlMapperExtensions.TableNameMapper.GetInvocationList();
     foreach (TableNameMapperDelegate delegateTableNameMapper in delegados)
         Dapper.Contrib.Extensions.SqlMapperExtensions.TableNameMapper -= delegateTableNameMapper; 

     Delegate.RemoveAll(Dapper.Contrib.Extensions.SqlMapperExtensions.TableNameMapper, Dapper.Contrib.Extensions.SqlMapperExtensions.TableNameMapper);

     Dapper.Contrib.Extensions.SqlMapperExtensions.TableNameMapper -= tableNameDelegate;
     Dapper.Contrib.Extensions.SqlMapperExtensions.TableNameMapper = null;




Aucun commentaire:

Enregistrer un commentaire