开发者

Silverlight, WCF, MVVM and existing n-tier assemblies

I am trying to get my head around MVVM in Silverlight - mostly in the context of how I can fit it in to an existing architecture - or rather how I can merge an existing architecture in to it.

The architecture I have at the moment is basically your traditional n-tier with a service layer over the top of it. I have a service layer in WCF, an assembly for business logic and an assembly that contains business entities (entity framework).

The service layer in WCF is pretty straight forward, it just exposes the business logic layer and needs a few changes to make it more compatible with Silverlight. The business entities assembly is referenced by both the service layer and the logic layer so that they both use the same entities and anything consuming the service is also aware of those entities.

All is peachy.

Along comes Silverlight and MVVM. The View part is easy, thats all the ui stuff. The ViewModel and Model is where it gets interesting for me. In my min开发者_StackOverflow社区d the Model is my business entities assembly and the ViewModel is my business logic assembly.

If Silverlight consumes my WCF service, then this and the coupled business logic layer is definately my ViewModel. Now I have 2 problems; 1/ The ViewModel object need to live in my Silverlight project. 2/ The types (business entities) exposed by the WCF service are not compatible with Silverlight as the assemblies are not for Silverlight. Cue exception to this effect when I try and add the assembly as a reference.

So... how do I use my business entities as my model? Also - how do I use other .Net types such as System.ServiceProcess.ServiceController in my ViewModel?


I think you should look at WCF RIA Services.

https://www.silverlight.net/getstarted/riaservices/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜