locked
WCF RIA Service - Design Question RRS feed

  • Question

  • We have a Silverlight 4 LOB application which uses WCF RIA service. Currently we have just one WCF RIA service encapsulated in a separate WCF RIA service library. This contains around 300 operations related to all the entities required to be exposed to Silverlight client. Having one service with so many operations does not sound right. I’m looking for some guideline/resource on how this is typically handled in a Silverlight business application.  What’s the best practice to break the WCF RIA services?

    Even if we break the existing services to multiple services, there are few entities which are needed in all the services. If this is the case, is it ok to include the common entities in all the services? Any inputs on this will be very helpful

    Appreciate it.

    Tuesday, November 8, 2011 10:47 AM

Answers

  • The rule is that the minimum size/lifetime of a DomainService/DomainContext is a single Unit of Work. You can think of the UoW as being a single transaction if you are not familiar with the term. If you can split your DomainService into multiple pieces which can be saved separately from each other then you can/should do that. If you need any of the 300 operations in the same transaction at any point then they need to stay a single DomainService. You can split a DomainService across multiple partial classes if that helps you maintain it better though.

     

    EDIT: Whoops forgot the other part. Yes, you can use the same entity type across multiple DomainServices as long as you are using at least SP1 of RIA Services. However, you cannot share instances of an entity.

    Tuesday, November 8, 2011 11:33 AM

All replies

  • The rule is that the minimum size/lifetime of a DomainService/DomainContext is a single Unit of Work. You can think of the UoW as being a single transaction if you are not familiar with the term. If you can split your DomainService into multiple pieces which can be saved separately from each other then you can/should do that. If you need any of the 300 operations in the same transaction at any point then they need to stay a single DomainService. You can split a DomainService across multiple partial classes if that helps you maintain it better though.

     

    EDIT: Whoops forgot the other part. Yes, you can use the same entity type across multiple DomainServices as long as you are using at least SP1 of RIA Services. However, you cannot share instances of an entity.

    Tuesday, November 8, 2011 11:33 AM
  • Thank you!

    Wednesday, November 9, 2011 1:26 PM