private ISqlBuilder AggregateFunctionParser(MemberExpression expression, ISqlBuilder sqlBuilder, string functionName) { string columnName = expression.Member.Name; sqlBuilder.AddCalculateColumn($"{functionName}({sqlBuilder.Formate(columnName)})"); return(sqlBuilder); }
protected override ISqlBuilder GroupBy(MemberExpression expression, ISqlBuilder sqlBuilder) { var tableAlias = GetTableAlias(expression, sqlBuilder); var columnAlias = $"{tableAlias}{sqlBuilder.Formate(expression.Member.Name)} "; sqlBuilder.AddCalculateColumn(columnAlias); sqlBuilder.AppendGroupSql(columnAlias); return(sqlBuilder); }
protected override ISqlBuilder GroupBy(NewExpression expression, ISqlBuilder sqlBuilder) { for (int i = 0; i < expression.Arguments.Count; i++) { var memberExp = expression.Arguments[0] as MemberExpression; var memberInfo = expression.Members[0]; sqlBuilder.AddCalculateColumn($"{sqlBuilder.Formate(memberExp.Member.Name)} {sqlBuilder.Formate(memberInfo.Name)}"); sqlBuilder.AppendGroupSql($"{sqlBuilder.Formate(memberExp.Member.Name)}"); } return(sqlBuilder); }
protected override ISqlBuilder Sum(NewExpression expression, ISqlBuilder sqlBuilder) { if (expression.Arguments.Count > 1) { throw new Exception("Calculate method can only contain one property "); } var memberExp = expression.Arguments[0] as MemberExpression; var memberInfo = expression.Members[0]; sqlBuilder.AddCalculateColumn($"SUM({sqlBuilder.Formate(memberExp.Member.Name)}) {sqlBuilder.Formate(memberInfo.Name)}"); return(sqlBuilder); }
public ICalculateQueryAble <T> Count(Expression <Func <T, object> > expression = null) { _SqlBuilder.SetSqlCommandType(SqlCommandType.Calculate); _SqlBuilder.AppendCalculateSql($"SELECT {{0}} FROM {_MainTableName} "); if (expression != null) { SqlVistorProvider.Count(expression.Body, _SqlBuilder); } else { _SqlBuilder.AddCalculateColumn("COUNT(*) "); } return(new CalculateQueryAble <T>(_SqlBuilder, _DapperKitProvider)); }