示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="condition"></param>
        /// <returns></returns>
        public int Delete <T>(IDictionary <string, object> condition)
        {
            int    deletecount = 0;
            string tableName   = _database.GetTableName(typeof(T));

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

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

                deletecount = _database.Execute(sql, args);
            }

            return(deletecount);
        }