WCF RIA Services amazing! I use it in a several Silverlight projects and keep getting amazed.
Today I got a question about retrieving data from a Stored Procedure in Silverlight using WCF RIA Services and a LINQ-to-SQL datamodel.
The LINQ-to-SQL datamodel in this sample contains a table called Book and a stored procedure called GetBooks. The stored procedure returns a list of books from the Book table and it is attached to the datamodel.
I have created a domain service that use the datamodel to return data to the Silverlight client. In the service I have created a method called GetBooks – it returns an ObservableCollection of Books.
The stored procedure return an ISingleResult of GetBooksResult. I have tried to convert the result to an ObservableCollection without success (any ideas?). To fix this issue I loop the result and add the items to a new ObservableCollection.
Finally, on the Silverlight I call my domain service (_context) and invoke the GetBooksQuery method to get the result.
I got inspiration from this blog post by Scott Gu.