Question

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.

Était-ce utile?

La solution

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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top