LINQ Query

Discussion in 'ASP .Net' started by shapper, Oct 17, 2007.

  1. shapper

    shapper Guest

    Hello,

    I have 2 tables:
    [A] > Aid, Aname ...
    > Bid, Aid, Bname ...

    I need to get the records in B given a Bname and a Aname. I think I
    should use Inner Join.

    I wrote the following code:

    Dim Bs = From a In db.A _
    Join b In db.B _
    On a.Aid Equals b.Aid _
    Where a.Aname = AName And b.Bname = BName

    This is not working.
    What am I doing wrong?
    And is there Inner Join in LINQ?

    Thanks,
    Miguel
    shapper, Oct 17, 2007
    #1
    1. Advertising

  2. shapper

    sloan Guest

    int myOrderID = 10; // bad naming convention on purpose

    then some linq

    from o in db.Orders
    join od in db.OrderDetails
    on o_OrderID equals od.OrderID
    where o_OrderID > myOrderID



    I don't know. C# code above, but yours looks right.

    You may need to show more code.

    What is your AName and BName ?


    "shapper" <> wrote in message
    news:...
    > Hello,
    >
    > I have 2 tables:
    > [A] > Aid, Aname ...
    > > Bid, Aid, Bname ...
    >
    > I need to get the records in B given a Bname and a Aname. I think I
    > should use Inner Join.
    >
    > I wrote the following code:
    >
    > Dim Bs = From a In db.A _
    > Join b In db.B _
    > On a.Aid Equals b.Aid _
    > Where a.Aname = AName And b.Bname = BName
    >
    > This is not working.
    > What am I doing wrong?
    > And is there Inner Join in LINQ?
    >
    > Thanks,
    > Miguel
    >
    sloan, Oct 18, 2007
    #2
    1. Advertising

  3. shapper

    sloan Guest

    Dude,

    You crossposted in the dot.languages.vb newgroups.


    Please don't do this.





    "shapper" <> wrote in message
    news:...
    > Hello,
    >
    > I have 2 tables:
    > [A] > Aid, Aname ...
    > > Bid, Aid, Bname ...
    >
    > I need to get the records in B given a Bname and a Aname. I think I
    > should use Inner Join.
    >
    > I wrote the following code:
    >
    > Dim Bs = From a In db.A _
    > Join b In db.B _
    > On a.Aid Equals b.Aid _
    > Where a.Aname = AName And b.Bname = BName
    >
    > This is not working.
    > What am I doing wrong?
    > And is there Inner Join in LINQ?
    >
    > Thanks,
    > Miguel
    >
    sloan, Oct 18, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ChrisN
    Replies:
    1
    Views:
    521
    Alexey Smirnov
    Aug 7, 2007
  2. Alex Sauceda

    SQL Query to Linq (Group By and Sum)

    Alex Sauceda, Feb 4, 2008, in forum: ASP .Net
    Replies:
    6
    Views:
    40,986
    Alex Sauceda
    Feb 4, 2008
  3. Joey
    Replies:
    1
    Views:
    691
    bruce barker
    Apr 23, 2008
  4. Seb
    Replies:
    0
    Views:
    561
  5. George

    Linq or not Linq

    George, Nov 4, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    335
    Mike Gleason jr Couturier
    Nov 5, 2008
Loading...

Share This Page