You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using Dapper 2.0.123 and DapperExtensions 1.7
A generic error with be raise in DapperImplementor in the lines reported.
The code below work fine in version 1.6.3 but raise the reported issue in 1.7
How to Reproduce example:
public class RepositoryBase<TEntity> where TEntity : class
{
public DateTime CreationDate { get; set; }
public string CreationUser { get; set; }
}
public class UserLogin : RepositoryBase<UserLogin>
{
[Key]
public long UserID { get; set; }
public long EntityID { get; set; }
public static UserLogin Login()
{
using (SqlConnection cn = new SqlConnection(XXXXX))
{
cn.Update(userLogin);
}
return userLogin;
}
}
ricardommatias
pushed a commit
to ricardommatias/Dapper-Extensions
that referenced
this issue
Feb 6, 2024
Exception:
This operation is only valid on generic types.
at System.RuntimeType.GetGenericTypeDefinition()
at DapperExtensions.DapperImplementor.AddParameter[T](T entity, DynamicParameters parameters, IMemberMap prop, Boolean useColumnAlias)
at DapperExtensions.DapperImplementor.GetDynamicParameters[T](T entity, IClassMapper classMap, IList
1 sequenceColumn, IList
1 foreignKeys, IList1 ignoredColumns, Boolean useColumnAlias) at DapperExtensions.DapperImplementor.GetDynamicParameters[T](IClassMapper classMap, T entity, Boolean useColumnAlias) at DapperExtensions.DapperImplementor.InternalInsert[T](IDbConnection connection, T entity, IDbTransaction transaction, Nullable
1 commandTimeout, IClassMapper classMap, IList1 nonIdentityKeyProperties, IMemberMap identityColumn, IMemberMap triggerIdentityColumn, IList
1 sequenceIdentityColumn)at DapperExtensions.DapperAsyncImplementor.InternalInsertAsync[T](IDbConnection connection, T entity, IDbTransaction transaction, Nullable
1 commandTimeout, IClassMapper classMap, IList
1 nonIdentityKeyProperties, IMemberMap identityColumn, IMemberMap triggerIdentityColumn, IList1 sequenceIdentityColumn) at DapperExtensions.DapperAsyncImplementor.InsertAsync[T](IDbConnection connection, T entity, IDbTransaction transaction, Nullable
1 commandTimeout)In DapperImplementor:
if (prop.MemberInfo.DeclaringType == typeof(bool) || (prop.MemberInfo.DeclaringType.IsGenericType && prop.MemberType.GetGenericTypeDefinition() == typeof(Nullable<>) && prop.MemberInfo.DeclaringType.GetGenericArguments()[0] == typeof(bool)))
{
...
}
There should be a check prop.MemberType.IsGenericType before prop.MemberType.GetGenericTypeDefinition()
The text was updated successfully, but these errors were encountered: