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. subquery in LINQ

subquery in LINQ

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqhelpquestion
4 Posts 2 Posters 3 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.
  • B Offline
    B Offline
    balaji t
    wrote on last edited by
    #1

    hi all, can any1 help me convert the following sub query in linq? select * from employee where employeeid in(select employeeid from dept where employeeid='E001'(I/P parameter)

    T.Balaji

    P 1 Reply Last reply
    0
    • B balaji t

      hi all, can any1 help me convert the following sub query in linq? select * from employee where employeeid in(select employeeid from dept where employeeid='E001'(I/P parameter)

      T.Balaji

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Without really trying this out, I would use

      var q = from p in employee
      where p.ID == (from d in dept select d.Employeeid)
      select p;

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      B 1 Reply Last reply
      0
      • P Pete OHanlon

        Without really trying this out, I would use

        var q = from p in employee
        where p.ID == (from d in dept select d.Employeeid)
        select p;

        Deja View - the feeling that you've seen this post before.

        My blog | My articles

        B Offline
        B Offline
        balaji t
        wrote on last edited by
        #3

        hi hanlon, var q = from p in employeewhere p.ID == (from d in dept select d.Employeeid)select p; == is 5n for a single row..but what abt if a query has multiple rows.Wont it return error "single row subquery returning more than 1 row"? Is there any equivalent keyword like "in"?i mean can we use like this? var q = from p in employeewhere p.ID in(from d in dept select d.Employeeid)select p;

        T.Balaji

        P 1 Reply Last reply
        0
        • B balaji t

          hi hanlon, var q = from p in employeewhere p.ID == (from d in dept select d.Employeeid)select p; == is 5n for a single row..but what abt if a query has multiple rows.Wont it return error "single row subquery returning more than 1 row"? Is there any equivalent keyword like "in"?i mean can we use like this? var q = from p in employeewhere p.ID in(from d in dept select d.Employeeid)select p;

          T.Balaji

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          balaji.t wrote:

          Wont it return error "single row subquery returning more than 1 row"? Is there any equivalent keyword like "in"?i mean can we use like this?

          No - it won't. Try it and see.

          Deja View - the feeling that you've seen this post before.

          My blog | My articles

          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