v2.6.0
Whats new?
- Added static field
TypeAttributeCache.CacheIsInitializedwhich is being used to check if theTypeAttributeCachehas already been initialized. This comes in handy when you'll need two differentIDbControllerimplementations within the same project. In addition it allows to manually setup the cache during application startup.
Breaking changes
The default static constructor implementation has been changed a little bit. The static constructor should now only initialize the TypeAttributeCache when this property is set to false.
You can update your static constructors to this code for example:
/// <summary>
/// Static constructor to initialize the TypeAttributeCache
/// </summary>
static MySqlController()
{
if (!TypeAttributeCache.CacheIsInitialized)
{
// INIT Dapper for CompareField
foreach (Type type in SingletonTypeAttributeCache.CacheAll<CompareFieldAttribute>((att) => att.FieldNames))
{
SqlMapper.SetTypeMap(type, new CustomPropertyTypeMap(
type,
(type, columnName) =>
{
PropertyInfo? prop = SingletonTypeAttributeCache.Get(type, columnName);
return prop is null ? type.GetProperty(columnName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance) : prop;
}
));
}
TypeAttributeCache.CacheIsInitialized = true;
}
}