From: hon123456 on
Dear all,

In SQL, there is a condition IN . e.g. products in (a,b,c). I
want to know whether there exist a same statement in C#. Or maybe I
should use other syntax? Thanks.
From: Patrice on
Hi,

We'll likely need some details as SQL is not C#. In particular this is the
other way round. Most collections have a method that allows to find out if
a value is found in the collection.

Try for example :
http://msdn.microsoft.com/en-us/library/bb384015.aspx

You could create an array that contains the a,b, c value and then test if
this array contains the products value...

--
Patrice

"hon123456" <peterhon321(a)yahoo.com.hk> a �crit dans le message de groupe de
discussion :
1aa8bbcf-8254-4222-af7d-294b3ae522d8(a)d30g2000prn.googlegroups.com...
> Dear all,
>
> In SQL, there is a condition IN . e.g. products in (a,b,c). I
> want to know whether there exist a same statement in C#. Or maybe I
> should use other syntax? Thanks.
>

From: Ovidiu Fragă on
On 24/03/2010 10:40, hon123456 wrote:
> Dear all,
>
> In SQL, there is a condition IN . e.g. products in (a,b,c). I
> want to know whether there exist a same statement in C#. Or maybe I
> should use other syntax? Thanks.
>
SELECT *
FROM
angajati
WHERE
angajati.nume_angajat IN
(SELECT
angajati.nume_angajat
FROM
angajati
WHERE
nume_angajat LIKE 'boc%')

where /angajati /is table name, and /nume_angajat/ is the field name.
you can pass this to a TableAdapter's SelectCommand.
From: Jeff Johnson on
"hon123456" <peterhon321(a)yahoo.com.hk> wrote in message
news:1aa8bbcf-8254-4222-af7d-294b3ae522d8(a)d30g2000prn.googlegroups.com...

> In SQL, there is a condition IN . e.g. products in (a,b,c). I
> want to know whether there exist a same statement in C#. Or maybe I
> should use other syntax? Thanks.

No, there is no direct C# equivalent to SQL's IN operator. You either have
to use multiple || operators or you need to process the possibilities in a
loop.


From: J.B. Moreno on
hon123456 <peterhon321(a)yahoo.com.hk> wrote:

> Dear all,
>
> In SQL, there is a condition IN . e.g. products in (a,b,c). I
> want to know whether there exist a same statement in C#. Or maybe I
> should use other syntax? Thanks.

Most collection classes such as arrays and list have a method named
"Contains". So you declare your array myarray and then see if it has
what your looking for using myarray.Contains(whatever).

You can also use LINQ to do the same thing.

--
J.B. Moreno