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); }
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); }