-
Oct 17th, 2011, 03:31 PM
#1
Thread Starter
New Member
Parent Child
I have a project that has two tables in it. Businesses and Address. One to many...Mutiple Suit info in the address table...regardless thats not the issue here...what I am trying to do is return all the businesses and as the user selects one of the businesses in the main grid it selects all the related recrods in the address table and displays them on another grid.
I have to main grid upa dn running and on change of selection I can pop a message box up with a particular field value from the Business table...so far so good...
But I am now trying to grab that selceted record and select all the related records in the other table and populate another grid...This is what I am runnign into issues....
I am bombing out on this line:
Dim loadOp = Me._OrganizationContext.Load(query)
I get this ERROR:
Data type(s) of the type parameter(s) in method 'Public Function Load(Of TEntity As System.ServiceModel.DomainServices.Client.Entity)(query As System.ServiceModel.DomainServices.Client.EntityQuery(Of TEntity)) As System.ServiceModel.DomainServices.Client.LoadOperation(Of TEntity)' cannot be inferred from these arguments. Specifying the data type(s) explicitly might correct this error.
I also tried this
Dim loadOp As LoadOperation(Of Address) = context.Load(context.query())
Any thoughts?
DOMAIN SERVICE
Code:
Public Function GetCoreBusinesses2() As IQueryable(Of CoreBusiness)
Return Me.ObjectContext.CoreBusinesses.OrderBy(Function(e) e.ID)
End Function
Public Function GetAddresses() As IQueryable(Of Address)
Return Me.ObjectContext.Addresses.OrderBy(Function(e) e.ID)
End Function
VB
Code:
Dim _selectedItem = TryCast(dataGrid1.SelectedItem, CoreBusiness)
Dim Test As String = _selectedItem.BusinessName
MessageBox.Show(Test)
Dim query = _OrganizationContext.Addresses().Where(Function(child) child.CB_ID = _selectedItem.ID)
Dim loadOp = Me._OrganizationContext.Load(query)
dataGrid2.ItemsSource = loadOp.Entities
-
Oct 18th, 2011, 09:37 AM
#2
Thread Starter
New Member
Re: Parent Child
This is where I am right now...I think I have straightened a few things out...especially the query itself...now pointing to the Domain Service and specified query within...There are not any coding errors beign returned...jsut when I run the code itself..
Code:
Dim _selectedItem = TryCast(dataGrid1.SelectedItem, CoreBusiness)
Dim _query = _OrganizationContext.GetAddressesQuery().Where(Function(child) child.CB_ID = _selectedItem.ID)
Dim loadOp = Me._OrganizationContext.Load(_query)
timeEntryDataGrid.ItemsSource = loadOp.Entities
When I run this code I am getting an error...Its pointing to "(_query)" on the third line
Error: Expression of type 'System.Nullable'1[System.Boolean]' cannot be used for return type 'System.Boolean'
THINK I AM GETTIGN CLOSE...Any thoughts on the error....
Do I leave the "child" in the Query above "Function(child) child.CB_ID" ., or do I replace this with a tabel name?
Last edited by jaykappy; Oct 18th, 2011 at 10:45 AM.
-
Oct 18th, 2011, 02:18 PM
#3
Thread Starter
New Member
Re: Parent Child
Anyone?
Is there something that I can test? The query? What its trying to return? I am at a loss here...
-
Oct 18th, 2011, 04:01 PM
#4
Thread Starter
New Member
Re: Parent Child
THINK I GOT IT....YEAAAAAAAAAA......Will get back to this forum and paste everything I have...
Hopefully I got it.....Stay tuned....if anyone is even reading this anymore...
.
-
Oct 19th, 2011, 02:49 PM
#5
Re: Parent Child
Originally Posted by jaykappy
Stay tuned....if anyone is even reading this anymore...
.
Really!? For a 2 day old thread?
Here's a couple of articles on working with related data.
Walkthrough: Displaying Related Data in a Silverlight Business Application
RIA Services and relational data
I would recommend creating another method on your domain service with a logical name like GetAddressesByBusinessID and pass in selectedItem.ID there.
Code:
Public Function GetAddressesByBusinessID(ByVal businessID) As IQueryable(Of Address)
Return GetAddresses.Where(Function(a) a.CB_ID = businessID)
End Function
Code:
ctx.Load(ctx.GetAddressesByBusinessIDQuery(selectedItem.ID))
It'll remove some of the logic from your code behind to the Domain Service where it belongs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|