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()); }
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."); }
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#"); }