Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Usage of In predicate in linq vb.net

Usage of In predicate in linq vb.net

Scheduled Pinned Locked Moved LINQ
csharplinqtutorialquestion
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nilish
    wrote on last edited by
    #1

    Hi How to use the In predicate in LINQ with VB.net ?

    H 1 Reply Last reply
    0
    • N Nilish

      Hi How to use the In predicate in LINQ with VB.net ?

      H Offline
      H Offline
      Howard Richards
      wrote on last edited by
      #2

      There isn't an In predicate in LINQ. I assume you mean the IN clause from SQL. e.g.

      SELECT * FROM Customers WHERE Country IN ('UK','Germany');

      There are several ways to do this. The simplest:

      Dim countries = new String() {"UK","Germany"}
      Dim query = from c in db.Customers _
      where countries.Contains(c.Country) _
      select c

      Note that LINQ to SQL translates the .Contains() function into an IN clause.

      'Howard

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups