开发者

MVVM using DataTable?

开发者 https://www.devze.com 2023-01-21 10:22 出处:网络
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

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 cl开发者_运维技巧asses to represent these datatable and implement MVVM architecture. ?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号