Esempio n. 1
0
 public override void SetupParameters()
 {
     if (Parameters == null)
     {
         Parameters = SqlParameterCollection.Create <TRequest>(Request,
                                                               ExecutionContext.SmartSqlConfig.Settings.IgnoreParameterCase);
     }
 }
Esempio n. 2
0
        public static int DyUpdate <TEntity>(this IDbSession dbSession, object entity, bool?enablePropertyChangedTrack)
        {
            var entityProxy = entity as IEntityPropertyChangedTrackProxy;

            if (!enablePropertyChangedTrack.HasValue)
            {
                enablePropertyChangedTrack = entityProxy != null;
            }

            if (enablePropertyChangedTrack == true)
            {
                enablePropertyChangedTrack = entityProxy != null;
            }

            var dyParams   = SqlParameterCollection.Create(entity, false);
            var tableName  = EntityMetaDataCache <TEntity> .TableName;
            var pkCol      = EntityMetaDataCache <TEntity> .PrimaryKey;
            var sqlBuilder = new StringBuilder();

            sqlBuilder.AppendFormat("Update {0} Set ", tableName);
            var isFirst = true;

            foreach (var paramKV in dyParams)
            {
                if (!EntityMetaDataCache <TEntity> .TryGetColumnByPropertyName(paramKV.Key, out var column))
                {
                    continue;
                }

                if (column.IsPrimaryKey)
                {
                    continue;
                }

                if (enablePropertyChangedTrack.Value && entityProxy.GetPropertyVersion(column.Property.Name) == 0)
                {
                    continue;
                }

                if (!isFirst)
                {
                    sqlBuilder.Append(",");
                }

                isFirst = false;
                AppendColumnEqParameter(sqlBuilder, dbSession.SmartSqlConfig.Database.DbProvider, column);
            }

            sqlBuilder.Append(" Where ");
            AppendColumnEqParameter(sqlBuilder, dbSession.SmartSqlConfig.Database.DbProvider, pkCol);
            return(dbSession.Execute(new RequestContext
            {
                RealSql = sqlBuilder.ToString(),
                Request = dyParams
            }));
        }
Esempio n. 3
0
        public override void SetupParameters()
        {
            bool ignoreParameterCase = false;

            if (ExecutionContext != null)
            {
                ignoreParameterCase = ExecutionContext.SmartSqlConfig.Settings.IgnoreParameterCase;
            }

            Parameters =
                SqlParameterCollection.Create <TRequest>(Request, ignoreParameterCase);
        }
Esempio n. 4
0
        public static int DyUpdate <TEntity>(this IDbSession dbSession, object entity, bool?enablePropertyChangedTrack)
        {
            var dyParams = SqlParameterCollection.Create(entity, false);
            var scope    = EntityMetaDataCache <TEntity> .Scope;

            return(dbSession.Execute(new RequestContext
            {
                Scope = scope,
                SqlId = CUDStatementName.UPDATE,
                Request = dyParams
            }));
        }
Esempio n. 5
0
 public override void SetupParameters()
 {
     Parameters = SqlParameterCollection.Create <TRequest>(this);
 }