You have come across a rather delicate issue. Since you are dealing with Silverlight, I assume you are using some kind of a WCF service to load your data. Sending an array of objects with your service methods is something that WCF services do not support innately. A DataContract is required in order to get the right data transported without losses which suggests strong typing. Having an array of anonymous objects as a return type for the service methods leads to incorrect serialization in most cases and that is why it is not recommended to try to send such objects. An alternative approach to stored procedures for handling more complex result sets as a binding source for a grid is to use LINQ to retrieve the data you need, expose a service method which returns a strongly typed collection of objects and use the asynchronous invocation of the method to populate your grid. If you must use stored procedures then I suggest casting the retrieved objects to something that can be serialized and sent safely with the service. If you know exactly what type of objects is retrieved with the stored procedures you can do the following:
Create a partial class that extends the definition of the Entity Diagrams context. Expose the stored procedures as methods which return a strongly typed array. Creating the partial class in a separate file guarantees that the code will not be lost when changes are introduced to the domain model as code is generated again. Assuming you have mapped the stored procedures and you can see them in the Model Schema Explorer, you can just cut the stored procedures related code from the EntityDiagrams file where the definition of the context resides and paste it to the new .cs file.
SqlParameter parameterEmployeeLastName =
List<SqlParameter> sqlParameters =
Order queryResult =
Even if you manage to load an array of anonymous objects through the service methods, the array cannot be bound correctly to a grid as you have already found out.
We have automated the process of creating WCF services to a great extent. If you haven’t already looked at our help resources, I propose you spend some time to get acquainted with what we offer:
Using WCF RIA Services
Using WCF Data Services
Do not hesitate to contact us if you need to continue the discussion on this or other topics. I would just ask you to provide some more information on the type of services you have chosen.
the Telerik team
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Telerik Public Issue Tracking
system and vote to affect the priority of the items