Possible in Linq to Sql?

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

    Possible in Linq to Sql?

    Hi,

    I have a sql statement which I'm trying to translate to Linq. Not
    sure how to do this.

    select *
    from Table1 t1
    inner join Table2 t2 on t1.Id = t2.ParentId AND t2.Type = 'A'

    Thanks
    Andy
  • Frans Bouma [C# MVP]

    #2
    Re: Possible in Linq to Sql?

    Andy wrote:
    Hi,
    >
    I have a sql statement which I'm trying to translate to Linq. Not
    sure how to do this.
    >
    select *
    from Table1 t1
    inner join Table2 t2 on t1.Id = t2.ParentId AND t2.Type = 'A'
    >
    Thanks
    Andy
    the second predicate has to be moved to the where clause. So
    t2.Type=='A' has to be in the where, the rest can be in the join.

    FB

    --
    ------------------------------------------------------------------------
    Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
    LLBLGen Pro website: http://www.llblgen.com
    My .NET blog: http://weblogs.asp.net/fbouma
    Microsoft MVP (C#)
    ------------------------------------------------------------------------

    Comment

    • Cowboy \(Gregory A. Beamer\)

      #3
      Re: Possible in Linq to Sql?

      Also a good place to start learning lambda expressions. :-)

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

      *************** *************** *************** ****
      | Think outside the box!
      |
      *************** *************** *************** ****
      "Frans Bouma [C# MVP]" <perseus.usenet NOSPAM@xs4all.n lwrote in message
      news:xn0fmywrb3 3a24000@news.mi crosoft.com...
      Andy wrote:
      >
      >Hi,
      >>
      >I have a sql statement which I'm trying to translate to Linq. Not
      >sure how to do this.
      >>
      >select *
      >from Table1 t1
      > inner join Table2 t2 on t1.Id = t2.ParentId AND t2.Type = 'A'
      >>
      >Thanks
      >Andy
      >
      the second predicate has to be moved to the where clause. So
      t2.Type=='A' has to be in the where, the rest can be in the join.
      >
      FB
      >
      --
      ------------------------------------------------------------------------
      Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
      LLBLGen Pro website: http://www.llblgen.com
      My .NET blog: http://weblogs.asp.net/fbouma
      Microsoft MVP (C#)
      ------------------------------------------------------------------------

      Comment

      Working...