今天工作遇到4.0新增语法 不解 请教 遂知

:指定参数

public DataTable TodayToTable(int userId)
{
return userId > 0 ? V_CN_TASK_VALID_SCORING_TODAY.QueryTable(condition: " WHERE 承接者Id = " + userId) : null;
}


其中的condition: " WHERE 承接者Id = " + userId就是指定参数 condition是QueryTable方法的参数

/// <summary>
/// 查询指定表的记录
/// </summary>
/// <param name="table">表名</param>
/// <param name="fields">SELECT 子句的字段名列表</param>
/// <param name="condition">查询条件</param>
/// <param name="args">以半角逗号分隔的命令参数名称列表</param>
/// <param name="vals">命令参数值数组(可选)</param>
/// <returns>查询结果</returns>
public static DataTable QueryTable(this string table, string fields = null, int? limit = null, string condition = null, string args = null, params object[] vals)
{
return GetTable(table.QueryDataSet(fields, limit, condition, args, vals), 0);
}


??运算符

var m_queryFields = fields.TrimNull() ?? "*";

等于

var m_queryFields = fields.TrimNull() ? "*":fields.TrimNull();



posted on 2012-02-13 15:17  深海大虾  阅读(554)  评论(0编辑  收藏  举报