Does Silverlight supports database connectivity?
Silverlight supports database connectivity. It is done through LINQ to SQL classes.
- Add a new Web to the solution for hosting the control" radio button is checked. And click on OK.
- Add a new LINQ to SQL class in App_Code folder
- Use server explorer and drag and drop the required table in DataClass
- Add a new Silverlight-enabled WCF Service in Web Project.
a. Write code on Service.cs to retrieve data from tables.
b. Use DataClassesDataContetxt class to create objects.
c. Use a variable to store the data from a table
The following two lines illustrates the connectivity and retrieving data from a table
DataClassesDataContext db = new DataClassesDataContext();
var vendors = from vendor in db.Vendors select vendor;
return vendors.ToList();
where Vendors is the name of the table. The ToList() function returns the rows of the table.