Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to mapped underscore column in dapper extension #307

Open
waqasahmed0323 opened this issue Oct 1, 2022 · 2 comments
Open

Unable to mapped underscore column in dapper extension #307

waqasahmed0323 opened this issue Oct 1, 2022 · 2 comments

Comments

@waqasahmed0323
Copy link

Hi, I have a user data model containing some underscore columns but I'm unable to insert, update and get records using the dapper extension library it is throwing a reflection error below you can see:

at DapperExtensions.ReflectionHelper.GetParameter(Type entityType, ISqlGenerator sqlGenerator, String propertyName, Object value) at DapperExtensions.DapperImplementor.AddParameter[T](T entity, DynamicParameters parameters, IMemberMap prop, Boolean useColumnAlias) at DapperExtensions.DapperImplementor.GetDynamicParameters[T](T entity, IClassMapper classMap, IList1 sequenceColumn, IList1 foreignKeys, IList1 ignoredColumns, Boolean useColumnAlias) at DapperExtensions.DapperImplementor.GetDynamicParameters[T](IClassMapper classMap, T entity, Boolean useColumnAlias) at DapperExtensions.DapperImplementor.InternalUpdate[T](IDbConnection connection, T entity, IClassMapper classMap, IPredicate predicate, IDbTransaction transaction, IList1 cols, Nullable1 commandTimeout, Boolean ignoreAllKeyProperties) at DapperExtensions.DapperAsyncImplementor.<InternalUpdateAsync>d__151.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at DapperExtensions.DapperAsyncImplementor.d__161.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at DapperExtensions.DapperAsyncImplementor.<UpdateAsync>d__31.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at DapperExtensions.AsyncDatabase.d__81.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()

User Data Model:

public class Permission { public Guid Id { get; set; } public string permission_code { get; set; } public string role_code { get; set; } public bool HasPermission { get; set; } public string PermissionStatus { get; set; } public string addl_data { get; set; } }

await db.Update(roleView, null, true);

Also, I set this property before and after the connection opened but this is not working throwing the above exception:

IDbConnection con = CreateConnection(); if (con == null) throw new ApplicationException("CreateConnection function did not return a valid connection"); DefaultTypeMap.MatchNamesWithUnderscores = true; con.Open();

@hatuan
Copy link

hatuan commented Jul 26, 2023

I have same problem too with predicates(Ex : var a = Predicates.Field<sys_status>(x => x.status_cd, Operator.Eq, "1"))
Here is error : 'cd was not found for sys_status'

@waqasahmed0323
Copy link
Author

Hi @hatuan,
I fixed in repo and created a pull request for approval to @valfrid-ly, waiting for approve once approved so you will get the fixed in github project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants