Solved

linq equivalent for "IN" operator in Select * FROM table where Id IN (Select Id FROM tableB)

Posted on 2014-12-15
2
103 Views
Last Modified: 2016-02-15
Is there a linq equivalent for "IN" operator in Select * FROM table where Id IN (Select Id FROM tableB)?
0
Comment
Question by:matthew phung
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 40501570
That's (almost) equal to an INNER JOIN, so maybe:

 Select distinct t.* FROM table t inner join tableb b where t.id = b.id
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 40501593
If I recall correctly, you can use the Contains extension method. It should get converted to the appropriate SQL syntax.

e.g.

var inner = from Id in tableB
            select Id;

var outer = from t in table
            where inner.Contains(t.Id)
            select t;

Open in new window

0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question