Possible in Linq to Sql?

A

Andy

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
 
F

Frans Bouma [C# MVP]

Andy said:
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#)
------------------------------------------------------------------------
 
C

Cowboy \(Gregory A. Beamer\)

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

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

*************************************************
| Think outside the box!
|
*************************************************
 
A

Andy

Andy wrote:
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.

I was digging around on the join clause, and it seems that it does the
join after loading the rows from sql. I'd rather the join be done at
the server though.

I found how to create Associations, and combined with DataLoadOptions
I can get everything in one query.

Thanks for the feedback though!
Andy
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top