Search code examples
c#silverlightwcf-ria-servicesriadomainservices

What are the advantages and disadvantages of single/multiple domainservices in RIA


When using the RIA services in Silverlight, I am wondering what is the best solution for numbers and organization of domainservices?

I have read some articles about this With many different statements, and found that some prefer:

  • One domainservice per viewmodel
  • One domainservice per Group of Objects (ie. orders, orderlines, Products etc.)
  • One domainservice for the Whole Application

and some more...

I think there are pros and cons on all different solutions, but I would like to hear if anyone has some real-life experience with this?

Any sharing of knowledge/experience is appreciated, as we are considering to rewrite/restructure the database layer of a major business Application.


Solution

  • I've never heard of "One domainservice per viewmodel", and I think it's against how RiaServices is designed.

    One DomainService per group of objects is probably the way to go if you have to deal with a large domainmodel. Take into account, however, that you'll get troubles when you 'll have to submit change for entity that belongs to two different domaincontext (i.e. Orders and Customers) in a single transaction: you'll have to call two different SubmitChanges.

    One DomainService for the whole application is definitely the way to go if your application it's not that big (I'll say < 100 domainmodel classes)