Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi I am new to Silverlight. I am using linq to sql and wcf to display data in datagrid. It is working fine when I created a fucntion for single table.
What about multiple tables and multiple fucntions? I tried the following but could not achieve it, please guide me.

ContactRecord.vb file
VB
Public Class ContactRecord
    Public FirstName As String
    Public LastName As String
    Public Email As String
    Public ProductId As Integer
    Public Name As String
    Public ProductNumber As String
End Class


Service File

VB
Public Class Service1
    <OperationContract()> _
    Public Function GetContacts() _
        As List(Of ContactRecord)
        Dim db As New DataClasses1DataContext()
        Dim contacts = _
        (From contact _
        In db.Contacts _
        Order By contact.FirstName, _
            contact.LastName _
        Select contact).Take(1000)
        Dim list As New List(Of ContactRecord)
        For Each c In contacts
            list.Add( _
                New ContactRecord With _
                     {.FirstName = c.FirstName, _
                      .LastName = c.LastName, _
                      .Email = c.EmailAddress})
        Next
        Return list
    End Function
End Class
Public Class Service2
    <OperationContract()> _
    Public Function GetProducts() As List(Of ContactRecord)
        Dim db As New DataClasses1DataContext
        Dim products = (From product In db.Products Order By product.ProductID, product.Name, product.ProductNumber Select product)
        Dim list As New List(Of ContactRecord)
        For Each c In products
            list.Add(New ContactRecord With {.ProductId = c.ProductID, .Name = c.Name, .ProductNumber = c.ProductNumber})
        Next
        Return list
    End Function
End Class


I have taken a data class to get the tables from database, and in the main page I am binding the data to datagrid.

VB
Private WithEvents mService As New ServiceReference1.Service1Client()
Private Sub mService_GetContactsCompleted(ByVal sender As Object, ByVal e As ServiceReference1.GetContactsCompletedEventArgs) Handles mService.GetContactsCompleted
       dataGrid1.ItemsSource = e.Result
       dataGrid1.Visibility = Windows.Visibility.Visible
   End Sub


But when I am trying to access the second method using service object of products. I am unable to see it in the service reference. Any guidance would be helpful. Thanks in advance.
Posted
Updated 2-Feb-11 0:22am
v4

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