コード例 #1
0
        private ConditionItem EntityToModel(CTMS_CONDITIONITEM entity)
        {
            if (entity == null)
            {
                return(null);
            }
            ConditionItem model = new ConditionItem()
            {
                ID                = entity.ID,
                Category          = entity.CATEGORY,
                CondType          = (CondType)entity.CONDTYPE,
                MetaDataID        = entity.METADATAID,
                Operator          = (Operator)entity.OPERATOR,
                OperateValue      = entity.OPERATEVALUE,
                LogicalOperator   = (LogicOperator)entity.LOGICALOPERATOR,
                ComboCondItemList = GetCondItemListByIDs(entity.CONDIDS),
                DataType          = (DataType)entity.DATATYPE,
                DisplayName       = entity.DISPLAYNAME,
                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,
                MetaDataName      = entity.METADATAID.HasValue? new MetaDataBLL().Get(entity.METADATAID.Value).DisplayName:null,
            };

            model.ComboCondItemNames = (model.ComboCondItemList != null && model.ComboCondItemList.Count > 0) ? string.Join(",", model.ComboCondItemList.Select(o => o.DisplayName)) : null;
            return(model);
        }
コード例 #2
0
 /// <summary>
 /// 根据ID获取元数据
 /// </summary>
 /// <param name="keyWord"></param>
 /// <returns></returns>
 public ConditionItem Get(int id)
 {
     using (DbContext db = new CRDatabase())
     {
         CTMS_CONDITIONITEM entity = db.Set <CTMS_CONDITIONITEM>().Find(id);
         if (entity == null || entity.ID <= 0)
         {
             return(null);
         }
         return(EntityToModel(entity));
     }
 }