RIA Services: Sending complex types to the client

Entity Framework 4 allows us to create complex types. Typically, such types are used to get the result of a stored procedure. However, when we try to send such a complex type using a WCF RIA Domain Service, the following error is encountered.

The entity ' StoredProcedure_Result' in DomainService 'MyDomainService' does not have a key defined. Entities exposed by DomainService operations must have at least one public property marked with the KeyAttribute.

What to do? Read the rest of this entry »

RIA Services: How dates are handled and sent across the wire

The current(July) preview of RIA Services handles DateTime objects in an strange manner. Many of silverlight developers have complained in Silverlight forums that their dates are messed up. In this post, I am listing down several observations as a reference. Note that my current settings are +6 GMT.

From 	DateTime.Kind 	 DateTime.Value        To     DateTime.Kind  DateTime.Value
---- 	-------------   ----------------       --     -------------  ---------------
Client 	Unspecified     2009-01-01 00:00     Server 	Utc         2008-12-31 18:00
Server 	Unspecified     2009-01-01 00:00     Client 	Utc         2008-12-31 18:00
Client 	Local 	        2009-01-01 00:00     Server 	Utc         2008-12-31 18:00
Server 	Local 	        2009-01-01 00:00     Client 	Utc         2008-12-31 18:00
Client 	Utc 	        2009-01-01 00:00     Server 	Utc         2009-01-01 00:00
Server 	Utc 	        2009-01-01 00:00     Client 	Utc         2009-01-01 00:00

We can see that whatever Datetime we send, RIA service converts it to UTC when received at the other end. This could be bearable up to some extent but the worst thing is that RIA domain service treats Unspecified dates as Local and performs respective time zone conversion. Also, there is a UsesUtcDateTimes overridable in DomainService class but currently it does not seem to produce any effect.

Notice that there is no such conversion when using a WCF service, so whatever datetime value and kind we send from one side is exactlyreceived the same at the other side.

Lets hope the issues are fixed in the next version of RIA services.

My sample application that I used to test the behavior of RIA Domain Service and WCF Service can be downloaded from here. Remember to rename it to .zip for extraction.