protected override SqlBuilder Select(MemberExpression expression, SqlBuilder sqlBuilder)
        {
            sqlBuilder.SetTableAlias(expression.Member.DeclaringType.Name);
            string tableAlias = sqlBuilder.GetTableAlias(expression.Member.DeclaringType.Name);

            if (!string.IsNullOrWhiteSpace(tableAlias))
            {
                tableAlias += ".";
            }
            sqlBuilder.SelectFields.Add(tableAlias + expression.Member.Name);
            return(sqlBuilder);
        }
        private SqlBuilder AggregateFunctionParser(MemberExpression expression, SqlBuilder sqlBuilder)
        {
            string aggregateFunctionName = new StackTrace(true).GetFrame(1).GetMethod().Name.ToLower();

            string tableName  = expression.Member.DeclaringType.Name;
            string columnName = expression.Member.Name;

            sqlBuilder.SetTableAlias(tableName);
            string tableAlias = sqlBuilder.GetTableAlias(tableName);

            if (!string.IsNullOrWhiteSpace(tableAlias))
            {
                tableName += " " + tableAlias;
                columnName = tableAlias + "." + columnName;
            }
            sqlBuilder.AppendFormat("select {0}({1}) from {2}", aggregateFunctionName, columnName, tableName);
            return(sqlBuilder);
        }
        protected override SqlBuilder Where(MemberExpression expression, SqlBuilder sqlBuilder)
        {
            if (expression.Expression.NodeType == ExpressionType.Constant)
            {
                object value = GetValue(expression);
                sqlBuilder.AddDbParameter(value);
            }
            else if (expression.Expression.NodeType == ExpressionType.Parameter)
            {
                sqlBuilder.SetTableAlias(expression.Member.DeclaringType.Name);
                string tableAlias = sqlBuilder.GetTableAlias(expression.Member.DeclaringType.Name);
                if (!string.IsNullOrWhiteSpace(tableAlias))
                {
                    tableAlias += ".";
                }
                sqlBuilder += " " + tableAlias + expression.Member.Name;
            }

            return(sqlBuilder);
        }
 protected override SqlBuilder OrderBy(MemberExpression expression, SqlBuilder sqlBuilder)
 {
     sqlBuilder.SetTableAlias(expression.Member.DeclaringType.Name);
     sqlBuilder += sqlBuilder.GetTableAlias(expression.Member.DeclaringType.Name) + "." + expression.Member.Name;
     return(sqlBuilder);
 }