When using the WCF RIA Services, especially in the scenario POCO Objects, you must notice a lot. In particular, the generation of the domain context code, could be very frustrating. If you use for example a POCO data model with complex entities - in my case public enum as member of a class – the doman context access layer on the client (for example Silverlight ) maybe not longer generated. An error message does not appear.
Another mistake I made in the POCO scenario:
It is also important that you directly use the given entities from the client side to be manipulated. I mean don’t cast or transfer the parameter of the Update-, Insert-, Delete-method in an other class or reference instead of the given object the instance of the underlying data collection of the domain service. When you do this, all changes of your entity will not be propergated back to the Silverlight client.
A POCO-Objects example:
My business object:
My base class, which implements INotifyPropertyChanged:
The domain service which using a data persistence class for the business objects:
In the Silverlight client you can call the Insert-Method in that way:
After the SubmitChanges() the changes will be propergated back from the RIA Domain Service to the Domain Context an the client side and the entity collection of the context contains the new object.
In a similiar way you can call a update method:
DataAnnotations for DomainService-Methods
|[Invoke]||For methods which don’t have the standard signature|
|[Delete]||Prefix: Delete orRemove|
|[Insert]||Prefix: Insert, Add or Create|
|[Update]||Prefix: Change, Update, Modify|
|[Query]||IQueryable mit Return value INumerable, IQueryable, oder Entity|
|[Ignore]||Not available in Domain context|
|[RequiresRole(“Role1”)]||User have to be in role “Role1”|
|[Query(IsComposable=false)]||Returns only one entity instance|