Hi,
So I have a WPF application accessing entities through WCF Data Services. At the moment, I am accessing the proxy class that implements the DataServiceContext directly in my ViewModel. For example:
this.context = new MyOwnDataServiceContext(new Uri("http://localhost/myowndataservice"));
I then populate entities on the ViewModel from this context appropriately. I am feeling that the best way to work with this is to inject it into my ViewModel via Unity. So, I would like to have something like this in the ViewModel constructor:
public MyViewModelConstructor(IMyOwnDataServiceContext myOwnDataServiceContext) {
this.context = myOwnDataServiceContext;
}
I would then work with the context as usual. How should I be handling this? Is this the correct approach? My proxy classes get auto-generated, so if I were to start defining interfaces on the client would I not then have to modify the proxy generation?
Also, if I were to have a dialog window instantiated from this particular view model such as when you may want to show a window for data input, would you just pass this context in the same way i.e. via dependency injection into the constructor through Unity?
Any comments most welcome.