scm0sml
asked on
using linq to sql where predicates
Hi,
If I have the following code:
dim costumeg as new costumegroup
'some code to populate costumeg here
'then we want to get costumegroups that are not the costumeG.
Dim query = GeneralHelper.CostumeGroup s.Where(Fu nction(x) .....
I've not used predicates before and am just feeling my way into linq to sql...
What do I need to do in this predicate?
The code plus a quick description would be good.
Thanks in advance.
If I have the following code:
dim costumeg as new costumegroup
'some code to populate costumeg here
'then we want to get costumegroups that are not the costumeG.
Dim query = GeneralHelper.CostumeGroup
I've not used predicates before and am just feeling my way into linq to sql...
What do I need to do in this predicate?
The code plus a quick description would be good.
Thanks in advance.
ASKER
excuse the stupidity but i'm doing:
Dim query = GeneralHelper.CostumeGroup s.Where(Fu nction(cg) cg <> costumeg)
and getting:
Error 3 Overload resolution failed because no accessible 'Where' can be called with these arguments:
Extension method 'Public Function Where(predicate As System.Func(Of CostumeGroup, Integer, Boolean)) As System.Collections.Generic .IEnumerab le(Of CostumeGroup)' defined in 'System.Linq.Enumerable': Nested function does not have a signature that is compatible with delegate 'System.Func(Of CostumeGroup, Integer, Boolean)'.
Dim query = GeneralHelper.CostumeGroup
and getting:
Error 3 Overload resolution failed because no accessible 'Where' can be called with these arguments:
Extension method 'Public Function Where(predicate As System.Func(Of CostumeGroup, Integer, Boolean)) As System.Collections.Generic
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This was the code i needed to solve my query
Sorry I couldn't assist here, I was in a C# mindset when I replied to this and didn't get the VB.NET syntax right (keywords instead of operators).
The shorthand here is that you want a function that takes in a costumegroup object and returns a boolean check that the passes in object does not equal the one created earlier. You can obviously use normal IF starement constraints like && and properties of the objects as well.
Open in new window