Sub Query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shapper

    #1

    Sub Query

    Hello,

    I have a sub query in a Linq query:

    var data = (from a in database.A
    select new B {
    B1 = (from b in database.B
    join b in database.B on a.AID equals
    b.AID
    select b).ToList(),
    B2 = ?????????
    }).ToList();

    I want B2 to be a conversion of B1 to Array.

    So B2 = B1.ToArray();

    But is it possible to make this in the Linq query?

    In SQL I would give a name to the table produced by the Sub Query and
    then I would use that.

    Thanks,
    Miguel
  • Cowboy \(Gregory A. Beamer\)

    #2
    Re: Sub Query

    Try writing multiple linq queries and using the results of the other queries
    in your final result. Not sure on the array part, however. Will have to mull
    that one over.

    --
    Gregory A. Beamer
    MVP, MCP: +I, SE, SD, DBA

    Subscribe to my blog


    or just read it:


    *************** *************** **************
    | Think outside the box! |
    *************** *************** **************
    "shapper" <mdmoura@gmail. comwrote in message
    news:487fd5e3-c87c-4705-b55d-0bf8b4c7678b@2g 2000hsn.googleg roups.com...
    Hello,
    >
    I have a sub query in a Linq query:
    >
    var data = (from a in database.A
    select new B {
    B1 = (from b in database.B
    join b in database.B on a.AID equals
    b.AID
    select b).ToList(),
    B2 = ?????????
    }).ToList();
    >
    I want B2 to be a conversion of B1 to Array.
    >
    So B2 = B1.ToArray();
    >
    But is it possible to make this in the Linq query?
    >
    In SQL I would give a name to the table produced by the Sub Query and
    then I would use that.
    >
    Thanks,
    Miguel

    Comment

    • shapper

      #3
      Re: Sub Query

      On Sep 26, 3:53 pm, "Cowboy \(Gregory A. Beamer\)"
      <NoSpamMgbwo... @comcast.netNoS pamMwrote:
      Try writing multiple linq queries and using the results of the other queries
      in your final result. Not sure on the array part, however. Will have to mull
      that one over.
      >
      --
      Gregory A. Beamer
      MVP, MCP: +I, SE, SD, DBA
      >
      Subscribe to my bloghttp://feeds.feedburne r.com/GregoryBeamer#
      >
      or just read it:http://feeds.feedburner.com/GregoryBeamer
      >
      *************** *************** **************
      | Think outside the box!                               |
      *************** *************** **************" shapper" <mdmo...@gmail. com>wrote in message
      >
      news:487fd5e3-c87c-4705-b55d-0bf8b4c7678b@2g 2000hsn.googleg roups.com...
      >
      Hello,
      >
      I have a sub query in a Linq query:
      >
           var data = (from a in database.A
                           select new B {
                             B1 = (from b in database.B
                                      join b in database.B on a.AID equals
      b.AID
                                      select b).ToList(),
                             B2 = ?????????
                             }).ToList();
      >
      I want B2 to be a conversion of B1 to Array.
      >
      So B2 = B1.ToArray();
      >
      But is it possible to make this in the Linq query?
      >
      In SQL I would give a name to the table produced by the Sub Query and
      then I would use that.
      >
      Thanks,
      Miguel
      Yes,

      I have this working as follows:

      var data = (from a in database.A
      select new B {
      B1 = (from b in database.B
      join b in database.B on a.AID equals
      b.AID
      select b).ToList()
      }).ToList();

      B2 = B1.Select(t =t.Property).To Array()

      I was just wondering if I could integrate this code line in the
      query ... just that.

      Thanks,
      Miguel

      Comment

      • carlos juan

        #4
        http://www.eggheadcafe .com


        <a href="http://www.eggheadcafe .com">http://www.eggheadcafe .com</a>

        Comment

        • eww

          #5
          eww


          <a href="http://www.eggheadcafe .com">http://www.eggheadcafe .com</a>

          Comment

          Working...