6

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?

Vaccano
  • 78,325
  • 149
  • 468
  • 850

2 Answers2

9

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.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • 3
    I believe there is an option in the WCF add ref settings and in svcutil.exe that will let you generate classes that implement INotifyPropertyChanged. – NathanAW Jul 05 '11 at 18:26
  • 3
    Also, if you use the "Add Service Reference" option through your project, the generated code automatically implements the `INotifyPropertyChanged` interface on the DataContracts. – myermian Jul 06 '11 at 04:48
1

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.

Emond
  • 50,210
  • 11
  • 84
  • 115