Databinding in Silverlight with databases other than with SQL Server
-
Hi, I am evaluating Silverlight as a UI for a new application and I'm looking for some advice. I'm fairly new to Silverlight. Background: I am working with a database that provides it's own ADO.NET native adapter. Using this native provider, I can define ADO.NET Commands ith SQL Statements and run ExecuteQuery methods against the database to retrieve datasets. This all works fine when building a traditional client/server thick client. Now to Silverlight.... I am of the understanding that Silverlight (any version) will need to call a WCF web service (typically hosted by a ASP.NET Web application on a web server somewhere) right ?. A proxy class built on the Silverlight side is what is used to drive the web service, and controls are bound to this class. I have managed to build a simple Silverlight application that takes the input of two integers and displays the sum. This is done by calling an AddIntegers web method exposed by the web service, which returns the sum as a result. So far so good. However ... How do I go about gettings rows of information, like, a resultset from my database and into SL ? Within by web method (say, ContactNames()), I can execute ADO.NET type commands to interact with my remote database, but once I get that dataset, I do not know how to return it to silverlight for populating into a grid... Any help would be greatly appreciated, articles, sample code, .. anything ... Thanks
-
Hi, I am evaluating Silverlight as a UI for a new application and I'm looking for some advice. I'm fairly new to Silverlight. Background: I am working with a database that provides it's own ADO.NET native adapter. Using this native provider, I can define ADO.NET Commands ith SQL Statements and run ExecuteQuery methods against the database to retrieve datasets. This all works fine when building a traditional client/server thick client. Now to Silverlight.... I am of the understanding that Silverlight (any version) will need to call a WCF web service (typically hosted by a ASP.NET Web application on a web server somewhere) right ?. A proxy class built on the Silverlight side is what is used to drive the web service, and controls are bound to this class. I have managed to build a simple Silverlight application that takes the input of two integers and displays the sum. This is done by calling an AddIntegers web method exposed by the web service, which returns the sum as a result. So far so good. However ... How do I go about gettings rows of information, like, a resultset from my database and into SL ? Within by web method (say, ContactNames()), I can execute ADO.NET type commands to interact with my remote database, but once I get that dataset, I do not know how to return it to silverlight for populating into a grid... Any help would be greatly appreciated, articles, sample code, .. anything ... Thanks
Typically you will want to exchange strongly typed classes. So, have your web method return
List<Customers>
(or whatever else you need), and then populate that data into a grid using data templates in Silveright. A google search for silverlight data templates will get you what you need on that end.modified on Friday, August 7, 2009 1:27 PM
-
Hi, I am evaluating Silverlight as a UI for a new application and I'm looking for some advice. I'm fairly new to Silverlight. Background: I am working with a database that provides it's own ADO.NET native adapter. Using this native provider, I can define ADO.NET Commands ith SQL Statements and run ExecuteQuery methods against the database to retrieve datasets. This all works fine when building a traditional client/server thick client. Now to Silverlight.... I am of the understanding that Silverlight (any version) will need to call a WCF web service (typically hosted by a ASP.NET Web application on a web server somewhere) right ?. A proxy class built on the Silverlight side is what is used to drive the web service, and controls are bound to this class. I have managed to build a simple Silverlight application that takes the input of two integers and displays the sum. This is done by calling an AddIntegers web method exposed by the web service, which returns the sum as a result. So far so good. However ... How do I go about gettings rows of information, like, a resultset from my database and into SL ? Within by web method (say, ContactNames()), I can execute ADO.NET type commands to interact with my remote database, but once I get that dataset, I do not know how to return it to silverlight for populating into a grid... Any help would be greatly appreciated, articles, sample code, .. anything ... Thanks
pisanis wrote:
I am of the understanding that Silverlight (any version) will need to call a WCF web service
You don't have to use WCF. For example a plain old XML (POX) web service could be used. Silverlight can bind directly to the returned XML or if necessary you could convert the returned XML to an object or collection of objects using perhaps LINQ to XML.
*edit* Oops - drifted into WPF Land there
:)pisanis wrote:
How do I go about gettings rows of information, like, a resultset from my database and into SL ?
pisanis wrote:
once I get that dataset, I do not know how to return it to silverlight
There's a variety of ways to accomplish this. If you choose to use WCF, you could return a collection of objects of a class that represents a row of data. You would convert dataset rows to this collection of objects, perhaps using LINQ to DataSet. You may also want to look into .NET RIA Services, which is still in development and will probably be officially part of .NET 4, but there is a preview version[^] available which is now licensed to use live.
Mark Salsbery Microsoft MVP - Visual C++ :java:
modified on Friday, August 7, 2009 1:30 PM
-
Hi, I am evaluating Silverlight as a UI for a new application and I'm looking for some advice. I'm fairly new to Silverlight. Background: I am working with a database that provides it's own ADO.NET native adapter. Using this native provider, I can define ADO.NET Commands ith SQL Statements and run ExecuteQuery methods against the database to retrieve datasets. This all works fine when building a traditional client/server thick client. Now to Silverlight.... I am of the understanding that Silverlight (any version) will need to call a WCF web service (typically hosted by a ASP.NET Web application on a web server somewhere) right ?. A proxy class built on the Silverlight side is what is used to drive the web service, and controls are bound to this class. I have managed to build a simple Silverlight application that takes the input of two integers and displays the sum. This is done by calling an AddIntegers web method exposed by the web service, which returns the sum as a result. So far so good. However ... How do I go about gettings rows of information, like, a resultset from my database and into SL ? Within by web method (say, ContactNames()), I can execute ADO.NET type commands to interact with my remote database, but once I get that dataset, I do not know how to return it to silverlight for populating into a grid... Any help would be greatly appreciated, articles, sample code, .. anything ... Thanks
The most of your questions are already answered by our Codeproject Silverlight Experts. I will just add one more point here. If you really want to return the DataSet from Service then you may want to check-out the code written by one of our Silverlight community members. The link for that is here[^]. But returning the dataset from service is not a good idea but the most of .NET developers who are familiar with .NET 1.1 and 2.0 still prefer to use DataSet. Another thing is that DataSet will not be supported in Silverlight.
Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) Microsoft MVP (Silverlight), WPF/Silverlight Insiders