문제

I want to be separate between ViewModel and Mode(Data Access Object Or Data Members). Please see below.

Major DAO

Public Class Major

       Public MajorID as Integer
       Public MajorName as String

End Class

Major VM

Public Class MajorVM

       Public Major as Major

End Class

But Major View Model take a reference for major. In this case, I would like to convert major object to majorvm object list. Please see below.

Dim MajorList as list(of Major) = GetAllMajorList()
Dim MajorVMList as List(of MajorVM)

MajorVMList = MajorList

How can I solve this? Thanks.

도움이 되었습니까?

해결책

Try this.

Dim MajorVMList as New List(of MajorVM)

For each item as Major in MajorList 

 Dim m as new Major
 Major.MajorID = item.MajorID
 Major.MajorName = item.MajorName

 MajorVMList.Add(Major)


Next
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top