예제 #1
0
 private List <SqlStatement> UpdateStatements(
     List <SqlStatement> statements,
     DateTime timestamp,
     SqlParamCollection param,
     bool otherInitValue = false,
     List <SqlStatement> additionalStatements = null)
 {
     var where = Rds.BinariesWhereDefault(this)
                 .UpdatedTime(timestamp, _using: timestamp.InRange());
     if (VerUp)
     {
         statements.Add(CopyToStatement(where, Sqls.TableTypes.History));
         Ver++;
     }
     statements.AddRange(new List <SqlStatement>
     {
         Rds.UpdateBinaries(
             where : where,
             param: param ?? Rds.BinariesParamDefault(this, otherInitValue: otherInitValue),
             countRecord: true)
     });
     if (additionalStatements?.Any() == true)
     {
         statements.AddRange(additionalStatements);
     }
     return(statements);
 }
예제 #2
0
 public BinaryModel(
     Context context,
     long binaryId,
     bool clearSessions     = false,
     MethodTypes methodType = MethodTypes.NotSet)
 {
     OnConstructing(context: context);
     Context  = context;
     TenantId = context.TenantId;
     BinaryId = binaryId;
     if (context.QueryStrings.ContainsKey("ver"))
     {
         Get(context: context,
             tableType: Sqls.TableTypes.NormalAndHistory,
             where : Rds.BinariesWhereDefault(this)
             .Binaries_Ver(context.QueryStrings.Int("ver")));
     }
     else
     {
         Get(context: context);
     }
     if (clearSessions)
     {
         ClearSessions(context: context);
     }
     MethodType = methodType;
     OnConstructed(context: context);
 }
        public ErrorData UpdateOrCreate(
            Context context,
            SiteSettings ss,
            SqlWhereCollection where = null,
            SqlParamCollection param = null)
        {
            SetBySession(context: context);
            var statements = new List <SqlStatement>
            {
                Rds.UpdateOrInsertBinaries(
                    where : where ?? Rds.BinariesWhereDefault(
                        context: context,
                        binaryModel: this),
                    param: param ?? Rds.BinariesParamDefault(
                        context: context,
                        ss: ss,
                        binaryModel: this,
                        setDefault: true))
            };
            var response = Repository.ExecuteScalar_response(
                context: context,
                transactional: true,
                selectIdentity: true,
                statements: statements.ToArray());

            BinaryId = (response.Id ?? BinaryId).ToLong();
            Get(context: context);
            return(new ErrorData(type: Error.Types.None));
        }
 public BinaryModel Get(
     Context context,
     Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
     SqlColumnCollection column   = null,
     SqlJoinCollection join       = null,
     SqlWhereCollection where     = null,
     SqlOrderByCollection orderBy = null,
     SqlParamCollection param     = null,
     bool distinct = false,
     int top       = 0)
 {
     where = where ?? Rds.BinariesWhereDefault(
         context: context,
         binaryModel: this);
     column = (column ?? Rds.BinariesDefaultColumns());
     join   = join ?? Rds.BinariesJoinDefault();
     Set(context, Repository.ExecuteTable(
             context: context,
             statements: Rds.SelectBinaries(
                 tableType: tableType,
                 column: column,
                 join: join,
                 where : where,
                 orderBy: orderBy,
                 param: param,
                 distinct: distinct,
                 top: top)));
     return(this);
 }
예제 #5
0
        public List <SqlStatement> UpdateStatements(
            Context context,
            SiteSettings ss,
            string dataTableName     = null,
            SqlParamCollection param = null,
            bool otherInitValue      = false,
            List <SqlStatement> additionalStatements = null)
        {
            var timestamp  = Timestamp.ToDateTime();
            var statements = new List <SqlStatement>();

            var where = Rds.BinariesWhereDefault(this)
                        .UpdatedTime(timestamp, _using: timestamp.InRange());
            if (VerUp)
            {
                statements.Add(Rds.BinariesCopyToStatement(
                                   where : where,
                                   tableType: Sqls.TableTypes.History));
                Ver++;
            }
            statements.AddRange(UpdateStatements(
                                    context: context,
                                    dataTableName: dataTableName,
                                    where : where,
                                    param: param,
                                    otherInitValue: otherInitValue));
            statements.AddRange(UpdateAttachmentsStatements(context: context));
            if (additionalStatements?.Any() == true)
            {
                statements.AddRange(additionalStatements);
            }
            return(statements);
        }
예제 #6
0
        public List <SqlStatement> UpdateStatements(
            SqlParamCollection param, bool paramAll = false)
        {
            var timestamp = Timestamp.ToDateTime();

            return(new List <SqlStatement>
            {
                Rds.UpdateBinaries(
                    verUp: VerUp,
                    where : Rds.BinariesWhereDefault(this)
                    .UpdatedTime(timestamp, _using: timestamp.InRange()),
                    param: param ?? Rds.BinariesParamDefault(this, paramAll: paramAll),
                    countRecord: true)
            });
        }
예제 #7
0
 public BinaryModel Get(
     Sqls.TableTypes tableType    = Sqls.TableTypes.Normal,
     SqlColumnCollection column   = null,
     SqlJoinCollection join       = null,
     SqlWhereCollection where     = null,
     SqlOrderByCollection orderBy = null,
     SqlParamCollection param     = null,
     bool distinct = false,
     int top       = 0)
 {
     Set(Rds.ExecuteTable(statements: Rds.SelectBinaries(
                              tableType: tableType,
                              column: column ?? Rds.BinariesDefaultColumns(),
                              join: join ?? Rds.BinariesJoinDefault(),
                              where : where ?? Rds.BinariesWhereDefault(this),
                              orderBy: orderBy,
                              param: param,
                              distinct: distinct,
                              top: top)));
     return(this);
 }
예제 #8
0
        public Error.Types UpdateOrCreate(
            RdsUser rdsUser          = null,
            SqlWhereCollection where = null,
            SqlParamCollection param = null)
        {
            SetBySession();
            var statements = new List <SqlStatement>
            {
                Rds.UpdateOrInsertBinaries(
                    selectIdentity: true,
                    where : where ?? Rds.BinariesWhereDefault(this),
                    param: param ?? Rds.BinariesParamDefault(this, setDefault: true))
            };
            var newId = Rds.ExecuteScalar_long(
                rdsUser: rdsUser,
                transactional: true,
                statements: statements.ToArray());

            BinaryId = newId != 0 ? newId : BinaryId;
            Get();
            return(Error.Types.None);
        }
예제 #9
0
 private List <SqlStatement> UpdateStatements(
     List <SqlStatement> statements,
     DateTime timestamp,
     SqlParamCollection param,
     bool paramAll = false,
     List <SqlStatement> additionalStatements = null)
 {
     statements.AddRange(new List <SqlStatement>
     {
         Rds.UpdateBinaries(
             verUp: VerUp,
             where : Rds.BinariesWhereDefault(this)
             .UpdatedTime(timestamp, _using: timestamp.InRange()),
             param: param ?? Rds.BinariesParamDefault(this, paramAll: paramAll),
             countRecord: true)
     });
     if (additionalStatements?.Any() == true)
     {
         statements.AddRange(additionalStatements);
     }
     return(statements);
 }