Example #1
0
 public SqlHaving(
     string columnBracket,
     string tableName          = null,
     object value              = null,
     string _operator          = "=",
     string multiParamOperator = " and ",
     SqlStatement sub          = null,
     string raw              = null,
     SqlHavingCollection or  = null,
     Sqls.Functions function = Sqls.Functions.None,
     bool subPrefix          = true,
     bool _using             = true)
 {
     ColumnBracket      = columnBracket;
     TableName          = tableName;
     Value              = value;
     Operator           = _operator;
     MultiParamOperator = multiParamOperator;
     Sub       = sub;
     Raw       = raw;
     Or        = or;
     Function  = function;
     SubPrefix = subPrefix;
     Using     = _using;
 }
Example #2
0
 public SqlColumnCollection Add(
     string columnBracket    = null,
     string tableName        = null,
     string columnName       = null,
     string _as              = null,
     Sqls.Functions function = Sqls.Functions.None,
     SqlStatement sub        = null)
 {
     if (!this.Any(o =>
                   o.ColumnBracket == columnBracket &&
                   o.TableName == tableName &&
                   o.ColumnName == columnName &&
                   o.As == _as &&
                   o.Function == function &&
                   o.Sub == sub))
     {
         Add(new SqlColumn(
                 columnBracket: columnBracket,
                 tableName: tableName,
                 columnName: columnName,
                 _as: _as,
                 function: function,
                 sub: sub));
     }
     return(this);
 }
        public static decimal Aggregate(
            Context context,
            SiteSettings ss,
            string view,
            string columnName,
            Sqls.Functions function)
        {
            if (ss == null)
            {
                return(0);
            }
            var apiContext = CreateContext(
                context: context,
                action: "Aggregate",
                id: ss.SiteId,
                apiRequestBody: view);

            var where = (view.IsNullOrEmpty()
                ? new View()
                : apiContext.RequestDataString.Deserialize <Api>()?.View)
                        ?.Where(
                context: apiContext,
                ss: ss);
            var column = ss.GetColumn(
                context: apiContext,
                columnName: columnName);

            if (where != null &&
                column?.TypeName == "decimal" &&
                apiContext.CanRead(ss: ss) &&
                column.CanRead(
                    context: context,
                    ss: ss,
                    mine: null,
                    noCache: true))
            {
                switch (ss.ReferenceType)
                {
                case "Issues":
                    return(Repository.ExecuteScalar_decimal(
                               context: apiContext,
                               statements: Rds.SelectIssues(
                                   column: Rds.IssuesColumn().Add(
                                       column: column,
                                       function: function),
                                   where : where)));

                case "Results":
                    return(Repository.ExecuteScalar_decimal(
                               context: apiContext,
                               statements: Rds.SelectResults(
                                   column: Rds.ResultsColumn().Add(
                                       column: column,
                                       function: function),
                                   where : where)));
                }
            }
            return(0);
        }
Example #4
0
 public SqlOrderBy(
     string columnBracket,
     Types orderType         = Types.asc,
     string tableName        = null,
     Sqls.Functions function = Sqls.Functions.None)
 {
     TableName     = tableName;
     ColumnBracket = columnBracket;
     OrderType     = orderType;
     Function      = function;
 }
Example #5
0
 public SqlOrderBy(
     string columnBracket    = null,
     Types orderType         = Types.asc,
     string tableName        = null,
     Sqls.Functions function = Sqls.Functions.None,
     SqlStatement sub        = null)
 {
     TableName     = tableName;
     ColumnBracket = columnBracket;
     OrderType     = orderType;
     Function      = function;
     Sub           = sub;
 }
 public SqlOrderByCollection Add(
     string columnBracket,
     SqlOrderBy.Types orderType,
     string tableName,
     Sqls.Functions function = Sqls.Functions.None)
 {
     if (orderType != SqlOrderBy.Types.release)
     {
         Add(new SqlOrderBy(
                 columnBracket: columnBracket,
                 orderType: orderType,
                 tableName: tableName,
                 function: function));
     }
     return(this);
 }
Example #7
0
 public SqlColumn(
     string columnBracket,
     string tableName        = null,
     string columnName       = null,
     string _as              = null,
     Sqls.Functions function = Sqls.Functions.None,
     bool adHoc              = false,
     SqlStatement sub        = null)
 {
     ColumnBracket = columnBracket;
     TableName     = tableName;
     ColumnName    = columnName;
     As            = _as;
     Function      = function;
     AdHoc         = adHoc;
     Sub           = sub;
 }
Example #8
0
 public SqlOrderBy(
     string columnBracket    = null,
     Types orderType         = Types.asc,
     string tableName        = null,
     string isNullValue      = null,
     Sqls.Functions function = Sqls.Functions.None,
     SqlStatement sub        = null,
     string raw = null)
 {
     ColumnBracket = columnBracket;
     OrderType     = orderType;
     TableName     = tableName;
     IsNullValue   = isNullValue;
     Function      = function;
     Sub           = sub;
     Raw           = raw;
 }
 public SqlOrderByCollection Add(
     string columnBracket       = null,
     SqlOrderBy.Types orderType = SqlOrderBy.Types.asc,
     string tableName           = null,
     string isNullValue         = null,
     Sqls.Functions function    = Sqls.Functions.None,
     SqlStatement sub           = null,
     string raw = null)
 {
     if (orderType != SqlOrderBy.Types.release)
     {
         Add(new SqlOrderBy(
                 columnBracket: columnBracket,
                 orderType: orderType,
                 tableName: tableName,
                 isNullValue: isNullValue,
                 function: function,
                 sub: sub,
                 raw: raw));
     }
     return(this);
 }
            private decimal CreateAggregate(object siteId, string columnName, string view, Sqls.Functions function)
            {
                var ss = SiteSettingsUtilities.Get(
                    context: Context,
                    siteId: siteId.ToLong());

                return(ServerScriptUtilities.Aggregate(
                           context: Context,
                           ss: ss,
                           view: view,
                           columnName: columnName,
                           function: function));
            }