Пример #1
0
        public HardwareDto GetDtoByID(int id)
        {
            HardwareDto hardwareDto    = new HardwareDto();
            var         hardwareDomain = _hardwareRepository.GetEntityByID(id);

            hardwareDto.ID         = hardwareDomain.ID;//这个ID不用给值,到时候返回也拿得到
            hardwareDto.Number     = hardwareDomain.Number;
            hardwareDto.Name       = hardwareDomain.Name;
            hardwareDto.CreateTime = hardwareDomain.CreateTime;
            hardwareDto.CreateUser = hardwareDomain.CreateUser;
            //转换id为项目名
            var projects = from r in _dataContext.Set <Project>() where r.ID == hardwareDomain.ID select r;

            foreach (var project in projects)
            {
                hardwareDto.Project = project.Name;
            }
            return(hardwareDto);
        }