Exemple #1
0
 /// <summary>
 /// 初始化Sql查询字段类
 /// </summary>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="aliasesName">字段别名</param>
 private SqlQueryField(String tableName, SqlAggregateFunction function, String columnName, String aliasesName)
 {
     this._tableName   = tableName;
     this._fieldName   = columnName;
     this._aliasesName = aliasesName;
     this._useFunction = true;
     this._function    = function.ToString().ToUpperInvariant();
 }
 /// <summary>
 /// 初始化Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="aliasesName">字段别名</param>
 private SqlQueryField(SelectCommand cmd, String tableName, SqlAggregateFunction function, String columnName, String aliasesName)
 {
     this._tableName = tableName;
     this._columnName = columnName;
     this._aliasesName = aliasesName;
     this._useFunction = true;
     this._function = function.ToString().ToUpperInvariant();
 }
 /// <summary>
 /// 初始化Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="aliasesName">字段别名</param>
 private SqlQueryField(SelectCommand cmd, String tableName, SqlAggregateFunction function, String columnName, Boolean useDistinct, String aliasesName)
 {
     this._tableName   = tableName;
     this._columnName  = columnName;
     this._aliasesName = aliasesName;
     this._useFunction = true;
     this._useDistinct = useDistinct;
     this._function    = function.ToString().ToUpperInvariant();
 }
Exemple #4
0
 /// <summary>
 /// 初始化新的Sql语句排序类
 /// </summary>
 /// <param name="baseCommand">选择语句</param>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="orderType">排序方式</param>
 private SqlOrder(SelectCommand baseCommand, String tableName, SqlAggregateFunction function, String columnName, Boolean useDistinct, SqlOrderType orderType)
 {
     this._tableName   = tableName;
     this._columnName  = columnName;
     this._orderType   = orderType;
     this._useFunction = true;
     this._useDistinct = useDistinct;
     this._function    = function.ToString().ToUpperInvariant();
 }
 /// <summary>
 /// 创建新的Sql条件语句
 /// </summary>
 /// <param name="function">合计函数类型</param>
 /// <param name="op">条件运算符</param>
 /// <param name="value">数据</param>
 /// <returns>Sql条件语句</returns>
 public static SqlBasicParameterCondition Create(SqlAggregateFunction function, SqlOperator op, Object value)
 {
     return(SqlCondition.Create(function, "*", op, value));
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="function">合计函数</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="aliasesName">字段别名</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function, Boolean useDistinct, String aliasesName)
 {
     return new SqlQueryField(cmd, String.Empty, function, "*", useDistinct, aliasesName);
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="aliasesName">字段别名</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function, String columnName, String aliasesName)
 {
     return new SqlQueryField(cmd, String.Empty, function, columnName, false, aliasesName);
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function, String columnName, Boolean useDistinct)
 {
     return(new SqlQueryField(cmd, String.Empty, function, columnName, useDistinct, String.Empty));
 }
Exemple #9
0
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="function">合计函数</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SqlAggregateFunction function)
 {
     return(new SqlQueryField(String.Empty, function, "*", String.Empty));
 }
Exemple #10
0
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="aliasesName">字段别名</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(String tableName, SqlAggregateFunction function, String columnName, String aliasesName)
 {
     return(new SqlQueryField(tableName, function, columnName, aliasesName));
 }
Exemple #11
0
 /// <summary>
 /// 创建新的Sql语句排序类
 /// </summary>
 /// <param name="cmd">选择语句</param>
 /// <param name="function">合计函数</param>
 /// <param name="orderType">排序方式</param>
 internal static SqlOrder InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function, SqlOrderType orderType)
 {
     return new SqlOrder(cmd, String.Empty, function, "*", false, orderType);
 }
Exemple #12
0
 /// <summary>
 /// 创建新的Sql语句排序类
 /// </summary>
 /// <param name="cmd">选择语句</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="orderType">排序方式</param>
 internal static SqlOrder InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function, String columnName, Boolean useDistinct, SqlOrderType orderType)
 {
     return new SqlOrder(cmd, String.Empty, function, columnName, useDistinct, orderType);
 }
Exemple #13
0
 /// <summary>
 /// 创建新的Sql语句排序类
 /// </summary>
 /// <param name="cmd">选择语句</param>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="orderType">排序方式</param>
 internal static SqlOrder InternalCreateFromAggregateFunction(SelectCommand cmd, String tableName, SqlAggregateFunction function, Boolean useDistinct, SqlOrderType orderType)
 {
     return new SqlOrder(cmd, tableName, function, "*", useDistinct, orderType);
 }
Exemple #14
0
 /// <summary>
 /// 创建新的Sql语句排序类
 /// </summary>
 /// <param name="cmd">选择语句</param>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="orderType">排序方式</param>
 internal static SqlOrder InternalCreateFromAggregateFunction(SelectCommand cmd, String tableName, SqlAggregateFunction function, String columnName, SqlOrderType orderType)
 {
     return new SqlOrder(cmd, tableName, function, columnName, false, orderType);
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="function">合计函数</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function)
 {
     return(new SqlQueryField(cmd, String.Empty, function, "*", false, String.Empty));
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="function">合计函数</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="aliasesName">字段别名</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function, Boolean useDistinct, String aliasesName)
 {
     return(new SqlQueryField(cmd, String.Empty, function, "*", useDistinct, aliasesName));
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="aliasesName">字段别名</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SelectCommand cmd, String tableName, SqlAggregateFunction function, String columnName, Boolean useDistinct, String aliasesName)
 {
     return(new SqlQueryField(cmd, tableName, function, columnName, useDistinct, aliasesName));
 }
Exemple #18
0
 /// <summary>
 /// 初始化新的Sql语句排序类
 /// </summary>
 /// <param name="baseCommand">选择语句</param>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="orderType">排序方式</param>
 private SqlOrder(SelectCommand baseCommand, String tableName, SqlAggregateFunction function, String columnName, Boolean useDistinct, SqlOrderType orderType)
 {
     this._tableName = tableName;
     this._columnName = columnName;
     this._orderType = orderType;
     this._useFunction = true;
     this._useDistinct = useDistinct;
     this._function = function.ToString().ToUpperInvariant();
 }
 /// <summary>
 /// 查询指定合计函数并返回当前语句
 /// </summary>
 /// <param name="function">合计函数类型</param>
 /// <returns>当前语句</returns>
 public SelectCommand Query(SqlAggregateFunction function)
 {
     this._queryFields.Add(SqlQueryField.InternalCreateFromAggregateFunction(function));
     return(this);
 }
Exemple #20
0
 /// <summary>
 /// 创建新的Sql语句排序类
 /// </summary>
 /// <param name="cmd">选择语句</param>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="orderType">排序方式</param>
 internal static SqlOrder InternalCreateFromAggregateFunction(SelectCommand cmd, String tableName, SqlAggregateFunction function, String columnName, SqlOrderType orderType)
 {
     return(new SqlOrder(cmd, tableName, function, columnName, false, orderType));
 }
Exemple #21
0
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SqlAggregateFunction function, String columnName)
 {
     return(new SqlQueryField(String.Empty, function, columnName, String.Empty));
 }
Exemple #22
0
 /// <summary>
 /// 创建新的Sql语句排序类
 /// </summary>
 /// <param name="cmd">选择语句</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="orderType">排序方式</param>
 internal static SqlOrder InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function, String columnName, Boolean useDistinct, SqlOrderType orderType)
 {
     return(new SqlOrder(cmd, String.Empty, function, columnName, useDistinct, orderType));
 }
 /// <summary>
 /// 查询指定合计函数并返回当前语句
 /// </summary>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数类型</param>
 /// <param name="fieldName">要查询的字段名</param>
 /// <returns>当前语句</returns>
 public SelectCommand Query(String tableName, SqlAggregateFunction function, String fieldName)
 {
     this._queryFields.Add(SqlQueryField.InternalCreateFromAggregateFunction(tableName, function, fieldName));
     return this;
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="aliasesName">字段别名</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function, String columnName, String aliasesName)
 {
     return(new SqlQueryField(cmd, String.Empty, function, columnName, false, aliasesName));
 }
Exemple #25
0
 /// <summary>
 /// 创建新的Sql语句排序类
 /// </summary>
 /// <param name="cmd">选择语句</param>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="orderType">排序方式</param>
 internal static SqlOrder InternalCreateFromAggregateFunction(SelectCommand cmd, String tableName, SqlAggregateFunction function, Boolean useDistinct, SqlOrderType orderType)
 {
     return(new SqlOrder(cmd, tableName, function, "*", useDistinct, orderType));
 }
 /// <summary>
 /// 查询指定合计函数并返回当前语句
 /// </summary>
 /// <param name="function">合计函数类型</param>
 /// <returns>当前语句</returns>
 public SelectCommand Query(SqlAggregateFunction function)
 {
     this._queryFields.Add(SqlQueryField.InternalCreateFromAggregateFunction(function));
     return this;
 }
Exemple #27
0
 /// <summary>
 /// 创建新的Sql语句排序类
 /// </summary>
 /// <param name="cmd">选择语句</param>
 /// <param name="function">合计函数</param>
 /// <param name="orderType">排序方式</param>
 internal static SqlOrder InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function, SqlOrderType orderType)
 {
     return(new SqlOrder(cmd, String.Empty, function, "*", false, orderType));
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="aliasesName">字段别名</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(String tableName, SqlAggregateFunction function, String columnName, String aliasesName)
 {
     return new SqlQueryField(tableName, function, columnName, aliasesName);
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 /// <param name="aliasesName">字段别名</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SelectCommand cmd, String tableName, SqlAggregateFunction function, String columnName, Boolean useDistinct, String aliasesName)
 {
     return new SqlQueryField(cmd, tableName, function, columnName, useDistinct, aliasesName);
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SqlAggregateFunction function, String columnName)
 {
     return new SqlQueryField(String.Empty, function, columnName, String.Empty);
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="function">合计函数</param>
 /// <param name="columnName">字段名称</param>
 /// <param name="useDistinct">是否保证记录唯一</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function, String columnName, Boolean useDistinct)
 {
     return new SqlQueryField(cmd, String.Empty, function, columnName, useDistinct, String.Empty);
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="function">合计函数</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SqlAggregateFunction function)
 {
     return new SqlQueryField(String.Empty, function, "*", String.Empty);
 }
 /// <summary>
 /// 创建新的Sql查询字段类
 /// </summary>
 /// <param name="cmd">源选择语句</param>
 /// <param name="function">合计函数</param>
 internal static SqlQueryField InternalCreateFromAggregateFunction(SelectCommand cmd, SqlAggregateFunction function)
 {
     return new SqlQueryField(cmd, String.Empty, function, "*", false, String.Empty);
 }
        /// <summary>
        /// 查询指定字段名并返回当前语句
        /// </summary>
        /// <typeparam name="T">实体类类型</typeparam>
        /// <param name="cmd">查询语句</param>
        /// <param name="expr">实体类属性</param>
        /// <param name="function">合计函数类型</param>
        /// <param name="aliasesName">字段名的别名</param>
        /// <exception cref="ExpressionInvalidException">表达式不正确</exception>
        /// <exception cref="NullAttributeException">没有设置特性</exception>
        /// <returns>当前语句</returns>
        /// <example>
        /// <code lang="C#">
        /// <![CDATA[
        /// public class UserRepository : DatabaseTable<User>
        /// {
        ///     //other necessary code
        ///
        ///     public Int32 Count()
        ///     {
        ///         return this.Select()
        ///             .Query<User>(c => c.UserID, SqlAggregateFunction.Count, "UserCount")
        ///             .Result<Int32>();
        ///
        ///         //SELECT COUNT(UserID) AS UserCount From tbl_Users
        ///     }
        /// }
        /// ]]>
        /// </code>
        /// </example>
        public static SelectCommand Query <T>(this SelectCommand cmd, Expression <Func <T, Object> > expr, SqlAggregateFunction function, String aliasesName)
        {
            DatabaseColumnAttribute attr = SelectCommandExtension.GetColumnAttribute(cmd, expr.Body);

            return(cmd.Query(function, attr.ColumnName, aliasesName));
        }
 /// <summary>
 /// 创建新的Sql条件语句
 /// </summary>
 /// <param name="function">合计函数类型</param>
 /// <param name="fieldName">要查询的字段名</param>
 /// <param name="op">条件运算符</param>
 /// <param name="value">数据</param>
 /// <returns>Sql条件语句</returns>
 public static SqlBasicParameterCondition Create(SqlAggregateFunction function, String fieldName, SqlOperator op, Object value)
 {
     return(new SqlBasicParameterCondition(SqlParameter.Create(String.Format("{0}({1})", function.ToString().ToUpperInvariant(), fieldName), value), op));
 }
 /// <summary>
 /// 查询指定合计函数并返回当前语句
 /// </summary>
 /// <param name="tableName">表格名称</param>
 /// <param name="function">合计函数类型</param>
 /// <param name="fieldName">要查询的字段名</param>
 /// <returns>当前语句</returns>
 public SelectCommand Query(String tableName, SqlAggregateFunction function, String fieldName)
 {
     this._queryFields.Add(SqlQueryField.InternalCreateFromAggregateFunction(tableName, function, fieldName));
     return(this);
 }