Пример #1
0
 /// <summary>
 /// 创建参数化查询对象实例
 /// </summary>
 /// <returns>参数化查询对象</returns>
 public ParameterizedQuery BuildQuery(DbQueryConfigures configures)
 {
     lock ( SyncRoot )
     {
         return(new ParameterizedQuery(textBuilder.ToString(), values.ToArray(), configures));
     }
 }
Пример #2
0
        /// <summary>
        /// 与另一个查询配置对象合并
        /// </summary>
        /// <param name="configures">要与当前查询配置对象合并的查询配置对象</param>
        /// <returns>返回自身便于链式调用</returns>
        public DbQueryConfigures MergeWith(DbQueryConfigures configures)
        {
            var result = new Dictionary <string, object>();

            var theirs = configures._settings.Keys;
            var mines  = _settings.Keys;

            foreach (var key in mines.Except(theirs))
            {
                result[key] = _settings[key];
            }

            foreach (var key in theirs.Except(mines))
            {
                result[key] = configures._settings[key];
            }



            foreach (var key in mines.Intersect(theirs))
            {
                _settings[key] = ResolveConflict(key, _settings[key], configures._settings[key]);
            }


            _settings = result;
            return(this);
        }
Пример #3
0
        /// <summary>
        /// 构建参数化查询对象
        /// </summary>
        /// <param name="template">查询文本模板</param>
        /// <param name="values">参数值</param>
        /// <param name="configures">查询配置数据</param>
        internal ParameterizedQuery(string template, object[] values, DbQueryConfigures configures = null) : base(configures)
        {
            TextTemplate = template ?? throw new ArgumentNullException(nameof(template));


            if (values == null)
            {
                throw new ArgumentNullException(nameof(values));
            }

            ParameterValues = new object[values.Length];
            values.CopyTo(ParameterValues, 0);
        }
Пример #4
0
 /// <summary>
 /// 创建使用指定查询配置的副本
 /// </summary>
 /// <param name="configures">查询配置</param>
 /// <returns>使用指定查询配置的副本</returns>
 protected internal override DbQuery Clone(DbQueryConfigures configures)
 {
     return(new StoredProcedureQuery(Name, Parameters, configures));
 }
Пример #5
0
 /// <summary>
 /// 创建 StoredProcedureExpression 对象
 /// </summary>
 /// <param name="name">存储过程名称</param>
 /// <param name="parameters">存储过程参数列表</param>
 /// <param name="configures">查询配置对象</param>
 public StoredProcedureQuery(string name, IDictionary <string, object> parameters, DbQueryConfigures configures = null) : base(configures)
 {
     _name       = name;
     _parameters = parameters;
 }
Пример #6
0
 /// <summary>
 /// 创建 StoredProcedureExpression 对象
 /// </summary>
 /// <param name="name">存储过程名称</param>
 /// <param name="configures">查询配置对象</param>
 public StoredProcedureQuery(string name, DbQueryConfigures configures = null) : this(name, new Dictionary <string, object>(), configures)
 {
 }
Пример #7
0
 /// <summary>
 /// 合并两个查询配置对象
 /// </summary>
 /// <param name="configures">查询配置</param>
 /// <param name="another">要进行合并的查询配置</param>
 /// <returns>合并后的查询配置对象</returns>
 public static DbQueryConfigures Merge(DbQueryConfigures configures, DbQueryConfigures another)
 {
     return(configures.Clone().MergeWith(another));
 }
Пример #8
0
 /// <summary>
 /// 创建使用新的查询配置的副本
 /// </summary>
 /// <param name="configures">要使用的查询配置</param>
 /// <returns></returns>
 protected internal override DbQuery Clone(DbQueryConfigures configures)
 {
     return(new ParameterizedQuery(TextTemplate, ParameterValues, configures));
 }
Пример #9
0
 /// <summary>
 /// 制作查询对象的副本
 /// </summary>
 /// <param name="configures">所需要采用的配置对象</param>
 /// <returns>查询对象的副本</returns>
 protected internal abstract DbQuery Clone(DbQueryConfigures configures);
Пример #10
0
 /// <summary>
 /// 创建 DbQuery 对象
 /// </summary>
 /// <param name="configures">查询配置</param>
 protected DbQuery(DbQueryConfigures configures)
 {
     Configures = configures ?? new DbQueryConfigures();
 }                                                  //禁止直接从此类型派生