Example #1
0
 private List <SqlStatement> UpdateStatements(
     List <SqlStatement> statements,
     DateTime timestamp,
     SqlParamCollection param,
     bool otherInitValue = false,
     List <SqlStatement> additionalStatements = null)
 {
     var where = Rds.DemosWhereDefault(this)
                 .UpdatedTime(timestamp, _using: timestamp.InRange());
     if (VerUp)
     {
         statements.Add(CopyToStatement(where, Sqls.TableTypes.History));
         Ver++;
     }
     statements.AddRange(new List <SqlStatement>
     {
         Rds.UpdateDemos(
             where : where,
             param: param ?? Rds.DemosParamDefault(this, otherInitValue: otherInitValue),
             countRecord: true)
     });
     if (additionalStatements?.Any() == true)
     {
         statements.AddRange(additionalStatements);
     }
     return(statements);
 }
        public ErrorData UpdateOrCreate(
            Context context,
            SiteSettings ss,
            SqlWhereCollection where = null,
            SqlParamCollection param = null)
        {
            SetBySession(context: context);
            var statements = new List <SqlStatement>
            {
                Rds.UpdateOrInsertDemos(
                    where : where ?? Rds.DemosWhereDefault(
                        context: context,
                        demoModel: this),
                    param: param ?? Rds.DemosParamDefault(
                        context: context,
                        ss: ss,
                        demoModel: this,
                        setDefault: true))
            };
            var response = Repository.ExecuteScalar_response(
                context: context,
                transactional: true,
                selectIdentity: true,
                statements: statements.ToArray());

            DemoId = (response.Id ?? DemoId).ToInt();
            Get(context: context);
            return(new ErrorData(type: Error.Types.None));
        }
 private List <SqlStatement> UpdateStatements(
     Context context,
     SiteSettings ss,
     string dataTableName     = null,
     SqlWhereCollection where = null,
     SqlParamCollection param = null,
     bool otherInitValue      = false)
 {
     return(new List <SqlStatement>
     {
         Rds.UpdateDemos(
             dataTableName: dataTableName,
             where : where,
             param: param ?? Rds.DemosParamDefault(
                 context: context,
                 ss: ss,
                 demoModel: this,
                 otherInitValue: otherInitValue)),
         new SqlStatement(Def.Sql.IfConflicted.Params(DemoId))
         {
             IfConflicted = true,
             Id = DemoId
         }
     });
 }
        public List <SqlStatement> CreateStatements(
            Context context,
            SiteSettings ss,
            string dataTableName      = null,
            Sqls.TableTypes tableType = Sqls.TableTypes.Normal,
            SqlParamCollection param  = null,
            bool otherInitValue       = false)
        {
            var statements = new List <SqlStatement>();

            statements.AddRange(new List <SqlStatement>
            {
                Rds.InsertDemos(
                    dataTableName: dataTableName,
                    tableType: tableType,
                    selectIdentity: true,
                    param: param ?? Rds.DemosParamDefault(
                        context: context,
                        ss: ss,
                        demoModel: this,
                        setDefault: true,
                        otherInitValue: otherInitValue))
            });
            return(statements);
        }
Example #5
0
 public List <SqlStatement> CreateStatements(
     Sqls.TableTypes tableType = Sqls.TableTypes.Normal,
     SqlParamCollection param  = null,
     bool paramAll             = false)
 {
     return(new List <SqlStatement>
     {
         Rds.InsertDemos(
             tableType: tableType,
             selectIdentity: true,
             param: param ?? Rds.DemosParamDefault(
                 this, setDefault: true, paramAll: paramAll))
     });
 }
Example #6
0
        public List <SqlStatement> UpdateStatements(
            SqlParamCollection param, bool paramAll = false)
        {
            var timestamp = Timestamp.ToDateTime();

            return(new List <SqlStatement>
            {
                Rds.UpdateDemos(
                    verUp: VerUp,
                    where : Rds.DemosWhereDefault(this)
                    .UpdatedTime(timestamp, _using: timestamp.InRange()),
                    param: param ?? Rds.DemosParamDefault(this, paramAll: paramAll),
                    countRecord: true)
            });
        }
Example #7
0
 public List <SqlStatement> CreateStatements(
     List <SqlStatement> statements,
     Sqls.TableTypes tableType = Sqls.TableTypes.Normal,
     SqlParamCollection param  = null,
     bool otherInitValue       = false)
 {
     statements.AddRange(new List <SqlStatement>
     {
         Rds.InsertDemos(
             tableType: tableType,
             setIdentity: true,
             param: param ?? Rds.DemosParamDefault(
                 this, setDefault: true, otherInitValue: otherInitValue))
     });
     return(statements);
 }
Example #8
0
        public Error.Types UpdateOrCreate(
            RdsUser rdsUser          = null,
            SqlWhereCollection where = null,
            SqlParamCollection param = null)
        {
            SetBySession();
            var statements = new List <SqlStatement>
            {
                Rds.UpdateOrInsertDemos(
                    where : where ?? Rds.DemosWhereDefault(this),
                    param: param ?? Rds.DemosParamDefault(this, setDefault: true))
            };
            var response = Rds.ExecuteScalar_response(
                rdsUser: rdsUser,
                transactional: true,
                selectIdentity: true,
                statements: statements.ToArray());

            DemoId = (response.Identity ?? DemoId).ToInt();
            Get();
            return(Error.Types.None);
        }
Example #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.UpdateDemos(
             verUp: VerUp,
             where : Rds.DemosWhereDefault(this)
             .UpdatedTime(timestamp, _using: timestamp.InRange()),
             param: param ?? Rds.DemosParamDefault(this, paramAll: paramAll),
             countRecord: true)
     });
     if (additionalStatements?.Any() == true)
     {
         statements.AddRange(additionalStatements);
     }
     return(statements);
 }