Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

INotifyPropertyChanged in WCF DataContracts

I am making some WCF services, and some of the consumers are Prism Apps.

To avoid having to copy the DataContract class to a client side class, they would like to have the contracts support INotifyPropertyChanged.

However, I have some clients that are MVC3 clients.

Is adding INotifyPropertyChanged support to the data contracts going to mess them up?

Also, I am planning to have my DataContracts also be my POCO objects from my Entity Framework db connection. Will INotifyPropertyChanged mess that up?

Or is INotifyPropertyChanged just a WPF thing and the other apps won't care about it?

like image 220
Vaccano Avatar asked Jul 05 '11 17:07

Vaccano


2 Answers

Or is INotifyPropertyChanged just a WPF thing and the other apps won't care about it?

INotifyPropertyChanged is just an interface that you could implement on your entities without messing anything. It is used primary with WPF and Silverlight and it won't have effect on other technologies that don't use it. So there shouldn't be any problems implementing it on your WCF data contracts. Although note that when you generate a strongly typed client proxy from this WCF service (either using svcutil.exe or Add Service Reference) the resulting entities will not implement this interface. They will be POCOs.

like image 61
Darin Dimitrov Avatar answered Nov 13 '22 13:11

Darin Dimitrov


Another option is to use MVVM in the WPF applications. The DataContract will be the Models (M) and the developer of the WPF application will have to create the ViewModel.

The ViewModel has to implement the INotifyPropertyChanged and will load its data from the Model.

like image 36
Emond Avatar answered Nov 13 '22 12:11

Emond