コード例 #1
0
ファイル: InternalDbContext.cs プロジェクト: jaykizhou/elinq
 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;
 }
コード例 #2
0
ファイル: ExceptionHelper.cs プロジェクト: jaykizhou/elinq
 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);
 }
コード例 #3
0
        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));
        }
コード例 #4
0
        public ExecutionService(InternalDbContext dbContext)
        {
            this.dbContext = dbContext;
            log            = dbContext.Log;
            if (log == null)
            {
                log = SqlLog.Debug;
            }

            if (exceptionConverter == null)
            {
                exceptionConverter = new SqlExceptionConverter();
            }
        }
コード例 #5
0
ファイル: DbExceptionLogger.cs プロジェクト: yinmin/elinq
        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);
        }
コード例 #6
0
ファイル: ExceptionHelper.cs プロジェクト: jaykizhou/elinq
        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);
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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();
                }
            }
        }
コード例 #9
0
 protected override void CreateTables(ISqlLog log, DatabaseScriptEntry script, IDbContext ctx)
 {
     script.SchemaScripts = null;
     base.CreateTables(log, script, ctx);
 }
コード例 #10
0
 protected override void CreateTables(ISqlLog log, DatabaseScriptEntry script, IDbContext ctx)
 {
     script.SchemaScripts = null;
     base.CreateTables(log, script, ctx);
 }
コード例 #11
0
        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();
                }
            }
        }
コード例 #12
0
ファイル: DbExceptionLogger.cs プロジェクト: yinmin/elinq
 public static void Error(this ISqlLog log, Exception ex)
 {
     Error(log, ex, null);
 }