Exemplo n.º 1
0
 /// <summary>
 /// 根据ID获取元数据
 /// </summary>
 /// <param name="keyWord"></param>
 /// <returns></returns>
 public MetaDataParam Get(int id)
 {
     using (DbContext db = new CRDatabase())
     {
         CTMS_METADATAPARAM entity = db.Set <CTMS_METADATAPARAM>().Find(id);
         if (entity == null || entity.ID <= 0)
         {
             return(null);
         }
         return(EntityToModel(entity));
     }
 }
Exemplo n.º 2
0
 public MetaDataParam EntityToModel(CTMS_METADATAPARAM entity)
 {
     if (entity == null)
     {
         return(null);
     }
     return(new MetaDataParam()
     {
         ID = entity.ID,
         MetaDataID = entity.METADATAID,
         ParamName = entity.PARAMNAME,
         ParamValue = entity.PARAMVALUE
     });
 }
Exemplo n.º 3
0
 /// <summary>
 /// 删除元数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Delete(int id)
 {
     if (id <= 0)
     {
         LogService.WriteInfoLog(logTitle, "试图删除为空的MetaDataParam实体!");
         throw new KeyNotFoundException();
     }
     using (DbContext db = new CRDatabase())
     {
         CTMS_METADATAPARAM entity = db.Set <CTMS_METADATAPARAM>().Find(id);
         if (entity != null)
         {
             db.Set <CTMS_METADATAPARAM>().Remove(entity);
         }
         return(db.SaveChanges() > 0);
     }
 }