Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi Experts,
I am beginner to wcf and i want to develop wcf service with the linq to sql or ado.net entity model , which need to be consume in asp.net webapplication, can any body explain or send me the walk through or any example.

Thanks in advance.
prasad
Posted

1 solution

let's start from dbml file(where we need to add the connections)
In dbml file we need to add connections from server explorer tables will be on left side and stored procedures will be on right hand side.


add the service Reference and any change in .svc file and on service client extensions please update service Reference.

In service file (.svc) we need to write all the functions required to execute for a given application

<OperationContract()> _
Public Function GetPublicHolidays(employeeID As String, StartDate As Date) As List(Of employees)
Dim db As New DataConnectivityDataContext
Dim q = (From e In db.employees Where e.employee_id = companyID e.holiday_date >= StartDate Select e).ToList
db.Dispose()
Return q

End Function

then in mainpage class call that function
please note:I am using async function so if you are using async function first install Async CTP 3.0 (for silvelight 4 and 5 )then add these two dll's
AsyncCTPLibrary_Silvelight.dll
AsyncCTPLibrary.dll

Private Async Function GetemplyeeData(employee_id As String, StDate As Date) As Task(Of ObservableCollection(Of projectname.ServiceReference1.employees))
Dim svc = New projectname.ServiceReference1.ShiftRosteringServiceClient()

Dim t1 = MyServiceClientExtensions.GetemployeeAsyncHelper(svc, employeeID, StDate)

Await t1
Dim s = t1.Result

Return s
End Function

in MyServiceClientExtensions add helper fuction like this:

Public Function GetEmployeeAsyncHelper(client As projectname.ServiceReference1.ShiftRosteringServiceClient, _
EmployeeID As String, StartDate As Date) As Task(Of ObservableCollection(Of projectname.ServiceReference1.employees))

Dim taskCompletion = New TaskCompletionSource(Of ObservableCollection(Of projectname.ServiceReference1.employees))()

AddHandler client.getemployeesCompleted, Sub(s, e)
If e.[Error] IsNot Nothing Then taskCompletion.TrySetException(e.[Error]) ElseIf e.Cancelled Then taskCompletion.TrySetCanceled() Else taskCompletion.TrySetResult(e.Result) End If
End Sub

client.getemployeeAsync(employeeID, StartDate)
Return taskCompletion.Task

End Function
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900