-
Notifications
You must be signed in to change notification settings - Fork 5
Add trackSql action to handle generated sql and params #1
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
base: master
Are you sure you want to change the base?
Conversation
| } | ||
|
|
||
| public static long Count<T>(this IDbConnection connection, Action<IRestrictable<T>> restrictions = null) | ||
| public static long Count<T>(this IDbConnection connection, Action<IRestrictable<T>> restrictions = null, Action<string> trackSql = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets use an object instead of string + list of obj - it will enable us to extend it later without breaking the contract
| var parameters = new List<object>(); | ||
| var sql = countByQuery.GetSql(restrictions, parameters); | ||
|
|
||
| trackSql?.Invoke(sql); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing the parameters
| private static IEnumerable<T> Run<T>(IDbConnection connection, string sql, List<object> parameters, IEnumerable<Property> properties, Action<SqlDescriptor> trackSql = null) | ||
| where T : class, new() | ||
| { | ||
| trackSql?.Invoke(new SqlDescriptor(sql, parameters)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extract to method and add try-catch to invocation - since this is an artifact and should not prevent the query to run
ysa23
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update the minor version
What I did
I've added an optional
Action<string, IList<object>> trackSql = nullargument to theQueryExtmethodsTBD - tests.