R
Roshawn
Hi,
I have three tables in my database that I'm working with for a specific query. The tables
are Merchants, Brands, and Products.
OK. The Products table contains foreign keys from both the Merchants and Brands tables.
What I'm trying to do is get a list of brands by merchant and if the number of products
listed under each brand is greater than zero.
You still there? OK. Here's the LINQ code I wrote to see if I could get it done:
'I created a DataContext object variable named db
Dim brands As List(Of Brand)
Dim myMerchant as Merchant
myMerchant = db.Merchants.Single(Function(m) m.mer_name = "Gucci")
'error happens on the line below
brands = db.Brands.Where(Function(b) b.Products(0).Merchant.name = myMerchant AndAlso
b.Products.Count > 0).ToList
This code totally bombed. A System.NotSupportedException is thrown, stating, "Method
'Product get_Item(Int32)' has no supported translation to SQL"
And that's as close to a workable solution as I've come. Using the iterator works in
other code that I use. Unfortunately for me, it doesn't work in this case.
What am I doing wrong? Can someone point me in the right direction? Your help will be
greatly appreciated.
Thanks,
Roshawn
I have three tables in my database that I'm working with for a specific query. The tables
are Merchants, Brands, and Products.
OK. The Products table contains foreign keys from both the Merchants and Brands tables.
What I'm trying to do is get a list of brands by merchant and if the number of products
listed under each brand is greater than zero.
You still there? OK. Here's the LINQ code I wrote to see if I could get it done:
'I created a DataContext object variable named db
Dim brands As List(Of Brand)
Dim myMerchant as Merchant
myMerchant = db.Merchants.Single(Function(m) m.mer_name = "Gucci")
'error happens on the line below
brands = db.Brands.Where(Function(b) b.Products(0).Merchant.name = myMerchant AndAlso
b.Products.Count > 0).ToList
This code totally bombed. A System.NotSupportedException is thrown, stating, "Method
'Product get_Item(Int32)' has no supported translation to SQL"
And that's as close to a workable solution as I've come. Using the iterator works in
other code that I use. Unfortunately for me, it doesn't work in this case.
What am I doing wrong? Can someone point me in the right direction? Your help will be
greatly appreciated.
Thanks,
Roshawn