예제 #1
0
        /// <summary>
        /// Entity转Model
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        private V_xy_sp_spiritskill  EntityToModel(xy_sp_spiritskill entity)
        {
            if (entity != null)
            {
                xy_sp_skillBLL      bll   = new xy_sp_skillBLL();
                V_xy_sp_spiritskill model = new V_xy_sp_spiritskill()
                {
                    SpiritSkillID = entity.SpiritSkillID,
                    SpiritID      = entity.SpiritID,
                    SkillID       = entity.SkillID,
                    IsReady       = entity.IsReady,
                    skill         = bll.Get(c => c.SkillID == entity.SkillID)
                };

                return(model);
            }

            return(null);
        }
예제 #2
0
        public V_xy_sp_spirit getSpiritContextByID(string SpiritID)
        {
            xy_sp_equipmentBLL eqBll = new xy_sp_equipmentBLL();
            xy_sp_skillBLL     skBll = new xy_sp_skillBLL();

            using (xy_sp_userspiritDAL dal = new xy_sp_userspiritDAL())
            {
                var q = from ent in dal._context.xy_sp_spirit
                        where ent.SpiritID == SpiritID
                        select ent;
                V_xy_sp_spirit spiritV = EntityToModel(q.FirstOrDefault());

                //查询装备
                var sps = from spEq in dal._context.xy_sp_spiritequipment
                          join eq in dal._context.xy_sp_equipment on spEq.EquipmentID equals eq.EquipmentID
                          where spEq.SpiritID == SpiritID
                          select eq;

                foreach (var spItem in sps)
                {
                    spiritV.spiritEquipmentList.Add(eqBll.EntityToModel(spItem));
                }

                //查询技能
                var sks = from SpiritSkill in dal._context.xy_sp_spiritskill
                          join Skill in dal._context.xy_sp_skill on SpiritSkill.SkillID equals Skill.SkillID
                          where SpiritSkill.SpiritID == SpiritID
                          select Skill;

                foreach (var skItem in sks)
                {
                    spiritV.spiritSkillList.Add(skBll.EntityToModel(skItem));
                }
                return(spiritV);
            }
        }