private DrugAllele EntityToModel(GN_DRUGALLELE entity) { if (entity == null) { return(null); } return(new DrugAllele() { ID = entity.ID, GeneAlleleID = entity.GENEALLELEID, DrugBankID = entity.DRUGBANKID, EffectType = entity.EFFECTTYPE, Effect = entity.EFFECT, CreateDateTime = entity.CREATEDATETIME, CreateUserID = entity.CREATEUSERID, CreateUserName = entity.CREATEUSERNAME, EditTime = entity.EDITDATETIME, EditUserID = entity.EDITUSERID, EditUserName = entity.EDITUSERNAME, OwnerID = entity.OWNERID, OwnerName = entity.OWNERNAME, IsDeleted = entity.ISDELETED }); }
/// <summary> /// 删除用户基因 /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Delete(string id) { if (string.IsNullOrEmpty(id)) { LogService.WriteInfoLog(logTitle, "试图删除ID为空的DrugAllele实体!"); return(false); } using (DbContext db = new CRDatabase()) { GN_DRUGALLELE entity = db.Set <GN_DRUGALLELE>().Find(id); if (entity != null) { db.Set <GN_DRUGALLELE>().Remove(entity); } return(db.SaveChanges() > 0); } }
/// <summary> /// 根据ID获取用户基因信息 /// </summary> /// <param name="id"></param> /// <returns></returns> public DrugAllele Get(string id) { if (string.IsNullOrEmpty(id)) { LogService.WriteInfoLog(logTitle, "试图查找ID为空的DrugAllele实体!"); return(null); } using (DbContext db = new CRDatabase()) { GN_DRUGALLELE entity = db.Set <GN_DRUGALLELE>().Find(id); if (entity == null) { return(null); } return(EntityToModel(entity)); } }