Exemplo n.º 1
0
        public string GenerateAggregateQuery(Database.AggregateFunction function, string propertyName, string fromTables)
        {
            var sqlFunction = function.ToString();

            var columnValueExpression = PropertyMappings[propertyName];

            if (function == Database.AggregateFunction.Average)
            {
                sqlFunction = "AVG";

                if (typeof(T).GetProperty(propertyName).PropertyType.IsAnyOf(typeof(int), typeof(int?)))
                {
                    columnValueExpression = $"CAST({columnValueExpression} AS decimal)";
                }
            }

            return($"SELECT {sqlFunction}({columnValueExpression}) FROM {fromTables}" + GenerateWhere());
        }
Exemplo n.º 2
0
 public object Aggregate(Type type, Database.AggregateFunction function, string propertyName, IEnumerable <ICriterion> conditions, params QueryOption[] options)
 {
     throw new NotSupportedException("Database.Aggregate doesn't work on interfaces.");
 }
Exemplo n.º 3
0
 public virtual object Aggregate(Type type, Database.AggregateFunction function, string propertyName, IEnumerable <ICriterion> conditions, params QueryOption[] options)
 {
     throw new NotImplementedException("Rebuild your project in M#");
 }