Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 4.5.1 General Discussion For ASP.NET 4.5.1 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4.5.1 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 25th, 2015, 10:59 AM
Authorized User
Points: 322, Level: 6
Points: 322, Level: 6 Points: 322, Level: 6 Points: 322, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2010
Posts: 63
Thanks: 3
Thanked 0 Times in 0 Posts
Default IQueryable

I have the following code
Dim users As IQueryable(Of view_user)
dim country as string

country= "USA"

users = From r In myentities.view_user Where r.country = country Select r

This works perfect. The problem is, that there may be more than one country (from 1 to n). How can I code this for n countries? the result should be

users = From r In myentities.view_user Where r.country = country or r.country=country2 and r.country=country3 .... r.country= countryn Select r

Thanks.
Alexander Avidan
Reply With Quote
  #2 (permalink)  
Old January 29th, 2017, 08:10 PM
Friend of Wrox
Points: 528, Level: 8
Points: 528, Level: 8 Points: 528, Level: 8 Points: 528, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2014
Posts: 136
Thanks: 1
Thanked 10 Times in 10 Posts
Default

see if the country is in a collection of valid countries


Code:
Dim validCountries() as string = GetValidCountries()


Dim userQuery = From r In myentities.view
               Where validCountries.Contains(r.country)
               Select r


Dim result = userQuery.ToArray()

Last edited by mmorgan30; January 29th, 2017 at 08:13 PM.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
public IQueryable Find method() bh81 BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 2 July 13th, 2011 07:47 AM



All times are GMT -4. The time now is 01:16 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.