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
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
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.
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.