Question Missing assembly reference namespace

kvic

New member
Joined
Aug 30, 2012
Messages
3
Programming Experience
10+
I keep getting this error message
is not queryable. Make sure you are not missing an assembly reference and/or namespace import for the LINQ

For Each r As product In DataStore.lm
count = (From n In r Where n.l1 = num Or n.l2 = num Or n.l3 = num Or n.l4 = num Or n.l5 = num Or n.l6 = num Or n.l7 = num Or n.l8 = num).Count
Next

Imports System.Collections.Generic
Imports System.Linq
Imports System.Linq.Expressions

It complains about r in the linq?


 
"From n In r" is like a "For Each n In r" loop, where r must be a queryable collection of some sort. Is one 'product' (r) a collection? Compiler says it is not.
 
If 'product' type (r) really was a ObservableCollection(Of T) collection you wouldn't have this problem.

Behind the scenes it works like this; ObservableCollection(Of T) inherits Collection(Of T) which implements IEnumerable(Of T). IEnumerable(Of T) is "queryable" by the LINQ to Objects provider as in-memory collections. This is covered by System.Linq namespace from System.Core assembly.
 
I don’t find the long

ObservableCollection(Of T) inherits Collection(Of T) which implements IEnumerable(Of T). IEnumerable(Of T) is "queryable" by the LINQ to Objects provider as in-memory collections. This is covered by System.Linq namespace from System.Core assembly.

Copy and pasted string useful for a forum that Newbie’s can ask for help

The Example that I provide was a generic example

Product of products so you would have understood more than most

Actually product is a collection of fields in the ObservableCollection(of Products)

If I cast the product to a collection or I should say Sequence of field objects for their values then I would have as you say a Queryable Collection

This would have been more useful and Newbie friendly
 
Back
Top