Silverlight 2.0 Application Development with LINQ to SQL and a WCF Service - WCF development
(Page 3 of 6 )
This is a continuation from the previous section.
Open “DemoEmpService” project and rename “Service1.svc” and “IService1.vb” to “EmpService.svc” and “IEmpService.vb” respectively (together with all of their associations). The steps are clearly explained in my previous article.
Configure the virtual path (using Project properties) to point to the local IIS and add ClientAccessPolicy.xml to IIS root (ex: c:inetpubwwwroot). The file is included in the attached source code and the steps are well explained in my previous article.
Open “IEmpService.vb” and modify the code so that it looks like the following:
<ServiceContract()> _
Public Interface IEmpService
<OperationContract()> _
Function GetEmployeeList() As List(Of Emp)
End Interface
Open “EmpService.svc” and modify the code as follows:
Imports System.Data.Linq
Public Class EmpService
Implements IEmpService
Public Sub New()
End Sub
Public Function GetEmployeeList() As System.Collections.Generic.List(Of Emp) Implements IEmpService.GetEmployeeList
Using ctxt As New DemoEmpDataContext
ctxt.ObjectTrackingEnabled = False
Return ctxt.Emps.ToList
End Using
End Function
End Class
Build your solution and test “EmpService.svc” using “WCF Test client” (explained in my previous article). You can also test the service using a WinForm application with the following code (the Win Form project is included in the attached source code):
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim obj As New EmpService.EmpServiceClient
Me.DataGridView1.DataSource = obj.GetEmployeeList
End Sub
End Class
Next: Silverlight development >>
More Windows Scripting Articles
More By Jagadish Chaterjee