Introducing Two-Way Data Binding using Silverlight 2.0, WCF and LINQ to SQL - Developing a Silverlight 2.0 page to demonstrate Insert functionality
(Page 2 of 5 )
Let us start with a new solution:
Create a new Visual Studio 2008 solution.
Add a new WCF Service project named "DemoEmpService."
Change "Service1" to "EmpService" everywhere in the project (steps are shown in my previous articles).
Add a "LINQ to SQL Classes" item to the project ("DemoEmp.dbml").
Using "Server Explorer," drag and drop "Emp" and "Dept" tables as shown in the following Fig 01.

' NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
<ServiceContract()> _
Public Interface IEmpService
<OperationContract()> _
Sub Add(ByVal objEmp As Emp)
End Interface
Imports System.Data.Linq
Public Class EmpService
Implements IEmpService
Public Sub New()
End Sub
Public Sub Add(ByVal objEmp As Emp) Implements IEmpService.Add
Using ctxt As New DemoEmpDataContext
'adding a new row
ctxt.GetTable(Of Emp).InsertOnSubmit(objEmp)
'saving rows added
ctxt.SubmitChanges()
End Using
End Sub
End Class
Add a new "Silverlight" project ("DemoSL") to the solution. This in turn will add a "DemoSL.Web" project (Silverlight hoster application) to the solution. Detailed steps are provided in previous articles.
Add a new "Silverlight user control" ("Page2.xaml") to the "DemoSL" project and modify "Application_Startup" in "App.xaml" as follows:
Private Sub Application_Startup(ByVal o As Object, ByVal e As StartupEventArgs) Handles Me.Startup
Me.RootVisual = New Page2()
End Sub
Next: Developing a Silverlight 2.0 page to demonstrate Add functionality, continued >>
More Windows Scripting Articles
More By Jagadish Chaterjee