示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="colmuns"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public int Update <T>(IDictionary <string, object> colmuns, IDictionary <string, object> condition)
        {
            int count = 0;

            string tableName = _database.GetTableName(typeof(T));

            if (!string.IsNullOrEmpty(tableName))
            {
                string   sql   = string.Empty;
                var      index = 0;
                object[] args  = new object[0];

                if (colmuns != null)
                {
                    var s = BuildUpdateColmunsSql(colmuns, ref index);
                    sql += string.Format("SET {0}", s);
                    args = args.Concat(colmuns.Select(x => x.Value)).ToArray();
                }

                if (condition != null)
                {
                    var s = BuildConditionSql(condition, ref index);
                    sql += string.Format(" WHERE {0}", s);
                    args = args.Concat(condition.Select(x => x.Value)).ToArray();
                }

                count = _database.Update <T>(sql, args);
            }
            return(count);
        }