Skip to content

Conversation

@igor-dv
Copy link

@igor-dv igor-dv commented Jan 25, 2018

What I did

I've added an optional Action<string, IList<object>> trackSql = null argument to the QueryExt methods

TBD - tests.

}

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)
Copy link
Contributor

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);
Copy link
Contributor

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));
Copy link
Contributor

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

Copy link
Contributor

@ysa23 ysa23 left a 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

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

Successfully merging this pull request may close these issues.

2 participants