Ejemplo n.º 1
0
 public IUpdateable <T> Where(bool isUpdateNull, bool IsOffIdentity = false)
 {
     UpdateBuilder.IsOffIdentity = IsOffIdentity;
     if (this.UpdateBuilder.LambdaExpressions == null)
     {
         this.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
     }
     this.UpdateBuilder.IsNoUpdateNull = isUpdateNull;
     return(this);
 }
Ejemplo n.º 2
0
 public IInsertable <T> IgnoreColumns(bool ignoreNullColumn, bool isOffIdentity = false)
 {
     Check.Exception(this.InsertObjs.Count() > 1 && ignoreNullColumn, ErrorMessage.GetThrowMessage("ignoreNullColumn NoSupport batch insert", "ignoreNullColumn 不支持批量操作"));
     this.IsOffIdentity = isOffIdentity;
     if (this.InsertBuilder.LambdaExpressions == null)
     {
         this.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
     }
     this.InsertBuilder.IsNoInsertNull = ignoreNullColumn;
     return(this);
 }
Ejemplo n.º 3
0
 public IUpdateable <T> IgnoreColumns(bool ignoreAllNullColumns, bool isOffIdentity = false, bool ignoreAllDefaultValue = false)
 {
     Check.Exception(this.UpdateObjs.Count() > 1 && ignoreAllNullColumns, ErrorMessage.GetThrowMessage("ignoreNullColumn NoSupport batch insert", "ignoreNullColumn 不支持批量操作"));
     UpdateBuilder.IsOffIdentity = isOffIdentity;
     if (this.UpdateBuilder.LambdaExpressions == null)
     {
         this.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.Context.CurrentConnectionConfig);
     }
     this.UpdateBuilder.IsNoUpdateNull         = ignoreAllNullColumns;
     this.UpdateBuilder.IsNoUpdateDefaultValue = ignoreAllDefaultValue;
     return(this);
 }
Ejemplo n.º 4
0
        protected DeleteableProvider <T> CreateDeleteable <T>() where T : class, new()
        {
            var result     = InstanceFactory.GetDeleteableProvider <T>(this.CurrentConnectionConfig);
            var sqlBuilder = InstanceFactory.GetSqlbuilder(this.CurrentConnectionConfig);;

            result.Context                             = this;
            result.SqlBuilder                          = sqlBuilder;
            sqlBuilder.DeleteBuilder                   = result.DeleteBuilder = InstanceFactory.GetDeleteBuilder(this.CurrentConnectionConfig);
            sqlBuilder.DeleteBuilder.Builder           = sqlBuilder;
            sqlBuilder.DeleteBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig);
            sqlBuilder.Context                         = result.SqlBuilder.DeleteBuilder.Context = this;
            return(result);
        }
Ejemplo n.º 5
0
        protected IDbLiteQueryable <T> CreateQueryable <T>(IDbLiteQueryable <T> result)
        {
            Check.Exception(typeof(T).IsClass() == false || typeof(T).GetConstructors().Length == 0, "Queryable<{0}> Error ,{0} is invalid , need is a class,and can new().", typeof(T).Name);
            var sqlBuilder = InstanceFactory.GetSqlbuilder(CurrentConnectionConfig);

            result.Context    = this.Context;
            result.SqlBuilder = sqlBuilder;
            result.SqlBuilder.QueryBuilder         = InstanceFactory.GetQueryBuilder(CurrentConnectionConfig);
            result.SqlBuilder.QueryBuilder.Builder = sqlBuilder;
            result.SqlBuilder.Context = result.SqlBuilder.QueryBuilder.Context = this;
            result.SqlBuilder.QueryBuilder.EntityType        = typeof(T);
            result.SqlBuilder.QueryBuilder.EntityName        = typeof(T).Name;
            result.SqlBuilder.QueryBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(CurrentConnectionConfig);
            return(result);
        }
Ejemplo n.º 6
0
        protected InsertableProvider <T> CreateInsertable <T>(T[] insertObjs) where T : class, new()
        {
            var result     = InstanceFactory.GetInsertableProvider <T>(this.CurrentConnectionConfig);
            var sqlBuilder = InstanceFactory.GetSqlbuilder(this.CurrentConnectionConfig);;

            result.Context                             = this;
            result.EntityInfo                          = this.Context.EntityMaintenance.GetEntityInfo <T>();
            result.SqlBuilder                          = sqlBuilder;
            result.InsertObjs                          = insertObjs;
            sqlBuilder.InsertBuilder                   = result.InsertBuilder = InstanceFactory.GetInsertBuilder(this.CurrentConnectionConfig);
            sqlBuilder.InsertBuilder.Builder           = sqlBuilder;
            sqlBuilder.InsertBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig);
            sqlBuilder.Context                         = result.SqlBuilder.InsertBuilder.Context = this;
            result.Init();
            return(result);
        }
Ejemplo n.º 7
0
        protected UpdateableProvider <T> CreateUpdateable <T>(T[] UpdateObjs) where T : class, new()
        {
            var result     = InstanceFactory.GetUpdateableProvider <T>(this.CurrentConnectionConfig);
            var sqlBuilder = InstanceFactory.GetSqlbuilder(this.CurrentConnectionConfig);;

            result.Context                             = this;
            result.EntityInfo                          = this.Context.EntityMaintenance.GetEntityInfo <T>();
            result.SqlBuilder                          = sqlBuilder;
            result.UpdateObjs                          = UpdateObjs;
            sqlBuilder.UpdateBuilder                   = result.UpdateBuilder = InstanceFactory.GetUpdateBuilder(this.CurrentConnectionConfig);
            sqlBuilder.UpdateBuilder.Builder           = sqlBuilder;
            sqlBuilder.UpdateBuilder.LambdaExpressions = InstanceFactory.GetLambdaExpressions(this.CurrentConnectionConfig);
            sqlBuilder.Context                         = result.SqlBuilder.UpdateBuilder.Context = this;
            result.Init();
            var ignoreColumns = result.EntityInfo.Columns.Where(it => it.IsOnlyIgnoreUpdate).ToList();

            if (ignoreColumns != null && ignoreColumns.Any())
            {
                result = (UpdateableProvider <T>)result.IgnoreColumns(ignoreColumns.Select(it => it.PropertyName).ToArray());
            }
            return(result);
        }