473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Linq Select in

Hi all,

Using studio 2008
Vista
MSSQL 2005

I am wanting to achive something like:
select * from mytable where mycolumn in (1,2,3)

How does one perform a select in, with linq

Thanks
Robert

Dec 12 '07 #1
2 10388
Robert Bravery <me@u.comwrote:
Using studio 2008
Vista
MSSQL 2005

I am wanting to achive something like:
select * from mytable where mycolumn in (1,2,3)

How does one perform a select in, with linq
Try Contains:

int[] options = {1, 2, 3};

var query = from row in mytable
where options.Contains(row.MyColumn)
select row;

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Dec 12 '07 #2
Thanks jon, that helped a lot. It worked

Robert

"Jon Skeet [C# MVP]" <sk***@pobox.comwrote in message
news:MP*********************@msnews.microsoft.com. ..
Robert Bravery <me@u.comwrote:
>Using studio 2008
Vista
MSSQL 2005

I am wanting to achive something like:
select * from mytable where mycolumn in (1,2,3)

How does one perform a select in, with linq

Try Contains:

int[] options = {1, 2, 3};

var query = from row in mytable
where options.Contains(row.MyColumn)
select row;

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Dec 13 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: shapper | last post by:
Hello, I have 3 SQL tables: TagId, TagText PostId, TagId, ... FileId, TagId, ... I need to, using LINQ, select all records in Tags, including the columns TagId and TagText, but adding...
4
by: BeSharp | last post by:
I recently stumbled across a pretty interesting LINQ to SQL question and wonder, whether anybody might have an answer. (I'm doing quite some increasing LINQ evangelism down here in Germany.). ...
7
by: Andy B | last post by:
Just wondering why linq is more useful than datasets? The stuff I do doesn't seem to be too complicated to use linq with it. If I did use linq with it now, I would be doing almost the exact same...
15
by: shapper | last post by:
Hello, I have two Lists: A = {ID, Name} = { (Null, John), (Null, Mary), (Null, Andrew), (Null, Peter) } B = {ID, Name} = { (1, John), (2, Robert), (3, Angela), (4, Andrew) } I want to...
2
by: shapper | last post by:
Hello, I have the following LINQ: List<Tagtags = (from t in database.Tags select t).ToList(); I need to restrict my results and for that I have two parameters: StartWidth and N
6
by: Plissskin | last post by:
I need to create an "ad-hoc" filtering page in a web app we are building. The page would display a number of drop down lists, text boxes, and radio lists and allow the user to select (enter) some...
14
by: thj | last post by:
Hi, I was wondering what you guys are using and why? LINQ to SQL or NHibernate? Thanks in advance, Tommy
7
by: shapper | last post by:
Hello, Is it possible to multiply all Prices in a List<Productby 1.1 using Linq? Product has a property named Price. Thanks, Miguel
21
by: hrishy | last post by:
Hi Will LINQ be ported to Python ? regards Hrishy
2
by: shapper | last post by:
Hello, I have the following Linq query: List<PostsTaginsert = (from t in (from t in database.Tags join p in paper.Tags on t.Name equals p.Name select t).ToList() select new PostsTag {
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.