tags:

views:

41

answers:

2

One of our legacy application is running in VB.net(3 tier) and DataTable is used as DTO. But we want to convert the application using WPF,MVVM architecture. Can i implement MVVM using Datatable as DTO or i have to create classes to represent these datatable and implement MVVM architecture. ?

+2  A: 

There's nothing in MVVM that precludes using a DataTable / DataSet as your model. The 'M' in MVVM can be anything really. It's the V and VM that are more clearly defined. Just have your ViewModel act as the go-between for your View and the underlying DataRow. It shouldn't be any more complicated than if your model were generated web service classes.

Josh Einstein
k, thnx. In Class we can implement the INotifyPropertychanged and even we can write the call backs,coercing etc. But in Datatable or in DataRow how can we identify the change notification? That's what foreced me to ask this question
Kishore Kumar
DataTable has a RowChanged event that you could use. But you probably don't need to use it. The ViewModel can raise the PropertyChanged events as required. The DataRow shouldn't change underneath the ViewModel too much if the ViewModel is controlling the data going into and out of the DataRow.
Josh Einstein
A: 

Look into the differences between using an anemic vs. rich model in MVVM. In the anemic model; which is what you get with a datatable, you implement properties and hook up all the INotify events in your VM. If you go the rich model route such as building you own business objects or using a framework like CSLA, then you get a lot more action from your model and your VM is much smaller/simpler.

DancesWithBamboo