Exemple #1
0
        /// <summary>
        /// 更新DataSet,如果DataSet中有行添加、删除或数据更新则按每条数据执行相应的SQL语句。
        /// 必须对已用Query对象查询出来的DataSet或者在Command中指定TableName。
        /// </summary>
        /// <param name="ds"></param>
        public void UpdateDataSet <T>(DataSet ds, QueryConditional <T> whereObject = null) where T : DbObject
        {
            var    table     = ds.Tables[0];
            string tableName = string.Empty;

            if (whereObject != null)
            {
                tableName = DbMetaDataManager.GetTableName(typeof(T));
            }
            else
            {
                tableName = table.TableName;
            }

            if (string.IsNullOrEmpty(tableName))
            {
                throw new InvalidOperationException("表名不能为空!");
            }
            string whereSQL = null;

            if (whereObject != null)
            {
                whereSQL = whereObject.ToString();
            }
            Provider.UpdateDataSet(ds, whereSQL);
        }
Exemple #2
0
        /// <summary>
        /// 条件查询
        /// </summary>
        /// <typeparam name="TModel"></typeparam>
        /// <param name="query"></param>
        /// <param name="qc">条件对象</param>
        /// <returns>查询构造器,后面可接其它查询构造器方法</returns>
        public static SelectQuery <TModel> Where <TModel>(this SelectQuery <TModel> query, QueryConditional <TModel> qc)
        {
            Regex  regex = new Regex(@"[a-z|A-Z]+\w*\.");
            string sql   = regex.Replace(qc.ToString(), @"T1.");

            query.WhereCreater.Append(" AND ")
            .Append(sql);


            return(query);
        }