private static string Insert <T>(IDictionary <string, object> parameters, bool returnScopeId = false, ITicket ticket = null, bool triggerEvent = false) { if (parameters is null) { throw new ArgumentNullException(nameof(parameters)); } if (parameters.Count <= 0) { throw new ArgumentOutOfRangeException(nameof(parameters)); } var sql = ticket is null ? ExtractInsert <T>(parameters, returnScopeId) : _queriesCache.GetOrAdd(ticket.Id, q => ExtractInsert <T>(parameters, returnScopeId)); if (!triggerEvent) { return(sql); } var eventArgs = new SqlEventArgs { Sql = sql, Parameters = parameters }; OnInserting?.Invoke(ticket, eventArgs); return(sql); }
private static string Select <T>(Condition condition, Dictionary <string, object> parameters, ITicket ticket = null, bool triggerEvent = false) { if (condition is null) { throw new ArgumentNullException(nameof(condition)); } if (parameters is null) { throw new ArgumentNullException(nameof(parameters)); } if (parameters.Count <= 0) { throw new ArgumentOutOfRangeException(nameof(parameters)); } string sql = ticket is null ? ExtractSql <T>(ClauseType.Select, condition) : _queriesCache.GetOrAdd(ticket.Id, q => ExtractSql <T>(ClauseType.Select, condition)); if (!triggerEvent) { return(sql); } var eventArgs = new SqlEventArgs { Sql = sql, Parameters = parameters }; OnSelecting?.Invoke(ticket, eventArgs); return(sql); }
private static string Update <T>(Clause clause, IDictionary <string, object> parameters, ITicket ticket = null, bool triggerEvent = false) { if (clause is null) { throw new ArgumentNullException(nameof(clause)); } if (parameters is null) { throw new ArgumentNullException(nameof(parameters)); } string sql = ticket is null ? ExtractSql <T>(ClauseType.Update, clause) : _queriesCache.GetOrAdd(ticket.Id, q => ExtractSql <T>(ClauseType.Update, clause)); if (!triggerEvent) { return(sql); } var eventArgs = new SqlEventArgs { Sql = sql, Parameters = parameters }; OnUpdating?.Invoke(eventArgs); return(sql); }
private static string InsertUnion <T>(IEnumerable <T> entities, IDictionary <string, object> parameters, ITicket ticket = null, bool triggerEvent = false) { if (entities is null) { throw new ArgumentNullException(nameof(entities)); } if (parameters is null) { throw new ArgumentNullException(nameof(parameters)); } if (parameters.Count <= 0) { throw new ArgumentOutOfRangeException(nameof(parameters)); } string sql = ticket is null ? BuildInsertUnionSql(entities) : _queriesCache.GetOrAdd(ticket.Id, q => BuildInsertUnionSql(entities)); if (!triggerEvent) { return(sql); } var eventArgs = new SqlEventArgs { Sql = sql, Parameters = parameters }; OnInserting?.Invoke(ticket, eventArgs); return(sql); }
private static string Select <T>(Clause clause, string selectClause, ITicket ticket = null, bool triggerEvent = false) { if (clause is null) { throw new ArgumentNullException(nameof(clause)); } string sql = ticket is null ? ExtractSql <T>(ClauseType.Select, clause, selectClause : selectClause) : _queriesCache.GetOrAdd(ticket.Id, q => ExtractSql <T>(ClauseType.Select, clause, selectClause: selectClause)); if (!triggerEvent) { return(sql); } var eventArgs = new SqlEventArgs { Sql = sql }; OnSelecting?.Invoke(ticket, eventArgs); return(sql); }
private static string Select <T>(Expression <Func <T, bool> > expression, Dictionary <string, object> parameters, ITicket ticket, bool triggerEvent = false) { if (expression is null) { throw new ArgumentNullException(nameof(expression)); } string sql = ticket is null ? BuildSql(ClauseType.Select, expression) : _queriesCache.GetOrAdd(ticket.Id, q => BuildSql(ClauseType.Select, expression)); if (!triggerEvent) { return(sql); } var eventArgs = new SqlEventArgs { Sql = sql, Parameters = parameters }; OnSelecting?.Invoke(ticket, eventArgs); return(sql); }
private static string Select <T>(IDbConnection connection, ITicket ticket = null, bool triggerEvent = false) { if (connection is null) { throw new ArgumentNullException(nameof(connection)); } string sql = ticket is null ? BuildSelectAllSql <T>() : _queriesCache.GetOrAdd(ticket.Id, q => BuildSelectAllSql <T>()); if (!triggerEvent) { return(sql); } var eventArgs = new SqlEventArgs { Sql = sql }; OnSelecting?.Invoke(ticket, eventArgs); return(sql); }
private static string Delete <T>(IDbConnection connection, IDictionary <string, object> parameters, ITicket ticket = null, bool triggerEvent = false) { if (connection is null) { throw new ArgumentNullException(nameof(connection)); } string sql = ticket is null ? BuildSql <T>(ClauseType.Delete, parameters) : _queriesCache.GetOrAdd(ticket.Id, q => BuildSql <T>(ClauseType.Delete, parameters)); if (!triggerEvent) { return(sql); } var eventArgs = new SqlEventArgs { Sql = sql, Parameters = parameters }; OnDeleting?.Invoke(ticket, eventArgs); return(sql); }