Well... I now think that the best way depends on where your data is.
If your data is stored in SQL or any ADO.Net datasource : use Linq to Entities in your service and serve entities as DataContracts throught Silverlight (I have not tested this but this sample looks great : http://www.codeproject.com/KB/silverlight/MySilverlightDataApp.aspx
). Also careful with this and SqlServer 2008 : Linq classes do not handle geometry and geography data......
If your data is stored the Xml way, you should have or build your DataSets and use Xsd.exe to generate classes (using xsd.exe /classes DstMyData.xsd /out:outdir). Those classes can be directly added to your Silverlight project to handle Xml data (by manually
loading xml data file with XDocument and putting the results in a DstMyData object), and / or can be used as DataContracts throught a WCF service. (this post was helpful : http://www.keithelder.net/blog/archive/2008/11/02/Creating-a-REST-WCF-Service-From-an-Existing-XSD-Schema.aspx)
... (if anyone can send here any other method, this could be great)
I used the second method and it works really great. The real big deal is to load the data to the classes generated by Xsd.exe (because the generated classes do not have constraints like real dataset classes do). But when that job is done, you can query your
classes via Linq in a really powerful SQL like way
So the tool you're looking for may be Xsd.exe if your data is xml, and should be Visual Studio and Linq to classes if your data is SQL or any database.
aixchile
Member
52 Points
19 Posts
Re: Re: Best practices for getting data throught WCF service ?
Feb 18, 2009 07:32 AM | LINK
Well... I now think that the best way depends on where your data is.
I used the second method and it works really great. The real big deal is to load the data to the classes generated by Xsd.exe (because the generated classes do not have constraints like real dataset classes do). But when that job is done, you can query your classes via Linq in a really powerful SQL like way
So the tool you're looking for may be Xsd.exe if your data is xml, and should be Visual Studio and Linq to classes if your data is SQL or any database.
Hope it helps !