Exemplo n.º 1
0
        public static int DeleteByPrimaryKey <T>(T t) where T : CAS.Entity.BaseDAModels.BaseTO, new()
        {
            int         result;
            BaseDAO <T> da = new BaseDAO <T>(GetConnectionName <T>());

            try
            {
                string tableName = GetEntityTable <T>();
                if (!string.IsNullOrEmpty(tableName))
                {
                    da.SetTableName(tableName);
                }
                result = da.DeleteByPK(t);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (t.IsSetCustomerFields)
                {
                    t.ClearFileds();
                }
                //自定义主键删除完毕,清除设置
                t.SetPrimaryKey <T>(null);
            }
            return(result);
        }
Exemplo n.º 2
0
        public static int DeleteByPrimaryKey <T>(string id) where T : CAS.Entity.BaseDAModels.BaseTO, new()
        {
            int         result;
            BaseDAO <T> da        = new BaseDAO <T>(GetConnectionName <T>());
            string      tableName = GetEntityTable <T>();

            if (!string.IsNullOrEmpty(tableName))
            {
                da.SetTableName(tableName);
            }
            result = da.DeleteByPK(id);
            return(result);
        }