Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 25th, 2015, 10:59 AM
Authorized User
 
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
 
Old January 29th, 2017, 09:10 PM
Friend of Wrox
 
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 09:13 PM..





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.