473,394 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to pass a LINQ query to a Sub and filter it?

Hello, I have a LINQ query:
Expand|Select|Wrap|Line Numbers
  1. Dim Db = New MyDataContext
  2. Dim Qry = From cust in Db.Customers
  3.      Select cust.ID, cust.Name
  4.  
And I want to pass it to a function to filter it, like this:
Expand|Select|Wrap|Line Numbers
  1. FilterQuery(Qry, ID)
  2. ...
  3.  
  4. Sub FilterQuery(ByVal MyQry as iQueryable, MyField as ???)
  5.   MyQry = MyQry.Where(MyField = "somevalue")
  6. End Sub
  7.  
How can I pass "MyField" to the Sub and make the LINQ "Where" clause work?
Is there any workaround?
Thank you.
Feb 6 '10 #1
0 1086

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: Marc Gravell | last post by:
In Linq, you can apparently get a meaningful body from and expression's .ToString(); random question - does anybody know if linq also includes a parser? It just seemed it might be a handy way to...
6
by: =?Utf-8?B?TmVkaW0=?= | last post by:
I am starting a new web application and I was planning on using linq but i have a bunch of problems. most forms will display some data from the database, but there always has to be a filtering...
22
by: paululvinius | last post by:
Hi! Testing som Linq-expressions and tried to measure performance and compare it to pre-Linq programming. The folloing two methods are functional equal but the non-Linq one is twice as fast....
1
by: PsychoPif | last post by:
Hello, I've heard that LINQ can do pretty much the same thing I could do if I could run an SQL query on my collection. I'd like to do something like this: Let's say I have and array of object...
8
by: Andy | last post by:
Hi, I'm trying to add a where clause to my query: List<stringtypes = new List<string>(); types.Add( "A" ); types.Add( "B" ); query = query.Where( c =types.Contains( c.Type ) );
3
by: MrEd | last post by:
Hi all I have a class that represents Accounts and each one of them has a property that has a list of tags (Tag is also a class) so i can do something like foreach (Tag currentTag in...
6
by: Plissskin | last post by:
I need to create an "ad-hoc" filtering page in a web app we are building. The page would display a number of drop down lists, text boxes, and radio lists and allow the user to select (enter) some...
4
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= | last post by:
I am trying to set up a dynamic search using linq. I believe the syntax is correct, but cannot confirm it because when I try to cast my Session from a List<to IQueryable<>, I get a cast error...
21
by: hrishy | last post by:
Hi Will LINQ be ported to Python ? regards Hrishy
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.