/// <summary>
        /// 删除语句
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t">删除条件实体</param>
        /// <returns></returns>
        public static bool DELETE <T>(T t)
        {
            string StrSql  = string.Empty;
            string WHERE   = string.Empty;
            string FAILEDS = string.Empty;

            Dictionary <string, object> dic = DictionaryName <T>(t);
            string PK = GetPrimaryKey(t.GetType().Name);

            StrSql = SQL_DELETE.Replace("[{TABLE_NAME}]", t.GetType().Name);
            foreach (var item in dic)
            {
                WHERE += " and " + item.Key + " ='" + item.Value + "' ";
            }
            StrSql = StrSql.Replace("{VALUES}", WHERE);
            return(ExecuteNonQuery(StrSql) > 0 ? true : false);
        }
示例#2
0
        private static void WriteDeletions(Stream stream, TableDescription[] tableDescriptions)
        {
            var deletions = tableDescriptions.Reverse().Select(tableDescription => SQL_DELETE.FormatInvariant(tableDescription.TableName()));

            stream.WriteLines(deletions);
        }