private InternalDbContext(DbConfiguration dbConfiguration, DbConnection conn, bool hasSelfCreateConnection) { Driver = dbConfiguration.Driver; Dialect = dbConfiguration.Dialect; this.dbConfiguration = dbConfiguration; connection = conn; Operations = new Dictionary <MemberInfo, List <LambdaExpression> >(); this.ExpressionBuilder = dbConfiguration.Option.DbExpressionBuilder; Log = dbConfiguration.sqlLogger(); HasSelfCreateConnection = hasSelfCreateConnection; }
public static Exception Convert(ISqlLog log, ISQLExceptionConverter converter, DbExceptionContextInfo exceptionContextInfo) { if (exceptionContextInfo == null) { throw new ArgumentNullException("The argument exceptionContextInfo is null."); } var sql = TryGetActualSqlQuery(exceptionContextInfo.SqlException, exceptionContextInfo.Sql); log.Error(exceptionContextInfo.SqlException, ExtendMessage(exceptionContextInfo.Message, sql)); return converter.Convert(exceptionContextInfo); }
public static Exception Convert(ISqlLog log, ISQLExceptionConverter converter, DbExceptionContextInfo exceptionContextInfo) { if (exceptionContextInfo == null) { throw new ArgumentNullException("The argument exceptionContextInfo is null."); } var sql = TryGetActualSqlQuery(exceptionContextInfo.SqlException, exceptionContextInfo.Sql); log.Error(exceptionContextInfo.SqlException, ExtendMessage(exceptionContextInfo.Message, sql)); return(converter.Convert(exceptionContextInfo)); }
public ExecutionService(InternalDbContext dbContext) { this.dbContext = dbContext; log = dbContext.Log; if (log == null) { log = SqlLog.Debug; } if (exceptionConverter == null) { exceptionConverter = new SqlExceptionConverter(); } }
public static void Error(this ISqlLog log, Exception ex, string message) { message = message ?? DefaultExceptionMsg; log.LogMessage(message); ex = ex.InnerException; while (ex != null) { log.LogMessage(ex.Message); ex = ex.InnerException; } log.LogMessage(Environment.NewLine); }
public static Exception Convert(ISqlLog log, ISQLExceptionConverter converter,DbExceptionContextInfo exceptionContextInfo, object[] parameterValues, NamedParameter[] namedParameters) { var sql = TryGetActualSqlQuery(exceptionContextInfo.SqlException, exceptionContextInfo.Sql); string extendMessage = ExtendMessage( exceptionContextInfo.Message, sql != null ? sql.ToString() : null, exceptionContextInfo.Entity, parameterValues, namedParameters); log.Error(exceptionContextInfo.SqlException, extendMessage); return converter.Convert(exceptionContextInfo); }
public static Exception Convert(ISqlLog log, ISQLExceptionConverter converter, DbExceptionContextInfo exceptionContextInfo, object[] parameterValues, NamedParameter[] namedParameters) { var sql = TryGetActualSqlQuery(exceptionContextInfo.SqlException, exceptionContextInfo.Sql); string extendMessage = ExtendMessage( exceptionContextInfo.Message, sql != null ? sql.ToString() : null, exceptionContextInfo.Entity, parameterValues, namedParameters); log.Error(exceptionContextInfo.SqlException, extendMessage); return(converter.Convert(exceptionContextInfo)); }
protected virtual void CreateTables(ISqlLog log, DatabaseScriptEntry script, IDbContext ctx) { var cmd = ctx.Connection.CreateCommand(); if (script.SequenceScripts != null && script.SequenceScripts.Length > 0) { foreach (var item in script.SequenceScripts) { cmd.CommandText = item; log.LogMessage(item); cmd.ExecuteNonQuery(); } } if (script.SchemaScripts != null && script.SchemaScripts.Length > 0) { foreach (var item in script.SchemaScripts) { cmd.CommandText = item; log.LogMessage(item); cmd.ExecuteNonQuery(); } } if (script.TableScripts != null && script.TableScripts.Length > 0) { foreach (var item in script.TableScripts) { cmd.CommandText = item; log.LogMessage(item); cmd.ExecuteNonQuery(); } } if (script.PKConstraintScripts != null && script.PKConstraintScripts.Length > 0) { foreach (var item in script.PKConstraintScripts) { cmd.CommandText = item; log.LogMessage(item); cmd.ExecuteNonQuery(); } } if (script.FKConstraintScripts != null && script.FKConstraintScripts.Length > 0) { foreach (var item in script.FKConstraintScripts) { cmd.CommandText = item; log.LogMessage(item); cmd.ExecuteNonQuery(); } } if (script.UniquleConstraintScripts != null && script.UniquleConstraintScripts.Length > 0) { foreach (var item in script.UniquleConstraintScripts) { cmd.CommandText = item; log.LogMessage(item); cmd.ExecuteNonQuery(); } } if (script.CheckConstraintScript != null && script.CheckConstraintScript.Length > 0) { foreach (var item in script.CheckConstraintScript) { cmd.CommandText = item; log.LogMessage(item); cmd.ExecuteNonQuery(); } } }
protected override void CreateTables(ISqlLog log, DatabaseScriptEntry script, IDbContext ctx) { script.SchemaScripts = null; base.CreateTables(log, script, ctx); }
public static void Error(this ISqlLog log, Exception ex) { Error(log, ex, null); }