标签:数据转换
今天写代码的时候突然“提笔忘字”,现在记录一下。
这个是由EF实体--->ViewModel实体--->泛型
<span style="font-family:KaiTi_GB2312;font-size:18px;">foreach (var roundCourse in roundCourseEntity) { AddRoundViewModel addRoundVM = new AddRoundViewModel(); //课程名称 addRoundVM.CourseName = roundCourse.BasicPublicChoseCourseCourseEntity.BasicOnClassEntity.OnClassName; //课程代码 addRoundVM.CourseCode = roundCourse.BasicPublicChoseCourseCourseEntity.BasicOnClassEntity.OnClassNo; //任课教师 addRoundVM.TeacherName = roundCourse.BasicPublicChoseCourseCourseEntity.BasicOnClassEntity.BasicTeacherEntity.Name; //课程性质 addRoundVM.CourseProperty = roundCourse.BasicPublicChoseCourseCourseEntity.CourseProperty; //开课学院 addRoundVM.OrganizationName = roundCourse.BasicPublicChoseCourseCourseEntity.BasicOnClassEntity.BasicCourseEntity.BasicOrganizationEntity.OrganizationName; //学分 addRoundVM.Credit = roundCourse.BasicPublicChoseCourseCourseEntity.BasicOnClassEntity.BasicCourseEntity.Credit; //总容量 addRoundVM.TtotalCapacity = (int)roundCourse.AllCapacity; //已选容量 addRoundVM.ChoosedCapacity = (int)roundCourse.AllChoosedCapacity; //剩余容量 addRoundVM.RemainCapacity = (int)roundCourse.RemainCapacity; //本轮可选容量 addRoundVM.CurrentSetCapacity = (int)roundCourse.CurrentSetCapacity; resultList.Add(addRoundVM); }</span>
这个是泛型--->泛型
<span style="font-family:KaiTi_GB2312;font-size:18px;"> List<StudentChooseCourseViewModel > listSturentChoosecourse=new List<StudentChooseCourseViewModel >() ; List<AddRoundViewModel > listAddRoundViewModel=new List<AddRoundViewModel > (); listAddRoundViewModel= iroundCourseBll.QueryRoundID(addRoundViewModel); for (int i = 0; i < listAddRoundViewModel.Count; i++) { //课程名称 listSturentChoosecourse[i].CourseName = listAddRoundViewModel[i].CourseName; //课程代码 listSturentChoosecourse[i].CourseCode = listAddRoundViewModel[i].CourseCode; //任课教师 listSturentChoosecourse[i].TeacherName = listAddRoundViewModel[i].TeacherName; //课程性质 listSturentChoosecourse[i].CourseProperty = listAddRoundViewModel[i].CourseProperty; //开课学院 listSturentChoosecourse[i].OrganizationName = listAddRoundViewModel[i].OrganizationName; //学分 listSturentChoosecourse[i].Credit = listAddRoundViewModel[i].Credit; //剩余容量 listSturentChoosecourse[i].RemainCapacity = listAddRoundViewModel[i].RemainCapacity; //本轮可选容量 listSturentChoosecourse[i].CurrentSetCapacity = listAddRoundViewModel[i].CurrentSetCapacity; //开课时间 listSturentChoosecourse[i].OnClassTime = listAddRoundViewModel[i].OnClassTime; }</span>
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:数据转换
原文地址:http://blog.csdn.net/u010924878/article/details/46867735