For our sample application, I have created pub database and within that database I have created Members table.
To create a supported database and table, I have included SQL Script in the source so run the sql script before moving forward because we need to have those database and table created while working with LINQ to SQL class.
Adding LINQ to SQL Class To add LINQ to SQL Class file, right click on silverlight web project and add new item and choose LINQ to SQL Classes template.
Once you click on Add it will open Data (object relational designer) file. It will open “Server Explorer” window where you can establish your sql server database connection.
To do that, click on interface class IData Service name, you will the smart tag poped up so click on “Implement interface IData Service” it will create implementation of “Get Members()” for you.(Easy to do that ah…. Only one thing is left to change for WCF service is that Http Binding in web.config.
WCF uses ws Http Binding by default and since Silverlight only supports basic httpbinding so change we need to change binding in web.config.
Click Ok to add reference of those operations in Silverlight class library project.
To do so, first create a web service client object and then wire up Get Members Completed event that will be called when asynchronous Get Members webservice call will be completed.
If you are not familiar with WCF Service, you can find out more about WCF here. There will be dummy contract “Do Work()” created in service contract file.
Replace that Do Work() contract with the contract method “Get Members” that we need to get the list of members object and also change the return type void to List.
Now build the solution to make sure all above steps went well.
Adding Reference in Silverlight Class Project Right click on Silverlight Class library - Add Service Reference.
You won’t find Row Edit Ended that is very useful event but was missing in Silverlight 2.0.