Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# LINQ
how can i use this query in Linq ---Select * from Table where NCM_SL IN(1,2)
Posted 29-Jul-10 22:04pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

here i am posting some thing about Linq basic operation select, insert, delete, update.
 

http://suhasharidas.blogspot.in/2012/08/create-linq-to-sql-connection-with.html[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try something like,
 
int[] serialNos= new int[] { 1, 2};
TableName.Where(p=>serialNos.Contains(p.NCM_SL))
 
OR
 
var objList = from p in TableName
              where serialNos.Contains(p.NCM_SL)
              select p;
 
Code is not tested so may be some minor changes will be needed.
  Permalink  
Comments
sanalpulikkal at 30-Jul-10 5:18am
   
Hai Arun,
I applied this code but i got some error like this..can u help me plz...
Instance Argument:Canot convert from 'int[]' to 'System.Collctions.Generic.IEnumerable'
public override IEnumerable GetFA_ACC_HEAD_IDS()
{
using (DC_FN_CONTEXTDataContext context = DataContext)
{
int[] serialNos = new int[] { 1, 2 };
var objList = from p in context.FA_ACC_HEADs
where serialNos.Contains(p.NSCHEDULE_SL)
select p;
return objList;
}
}
Sandeep Mewara at 30-Jul-10 5:22am
   
Comment from OP:
Hai Arun,
I applied this code but i got some error like this..can u help me plz...
Instance Argument:Canot convert from 'int[]' to 'System.Collctions.Generic.IEnumerable'
public override IEnumerable GetFA_ACC_HEAD_IDS()
{
using (DC_FN_CONTEXTDataContext context = DataContext)
{
int[] serialNos = new int[] { 1, 2 };
var objList = from p in context.FA_ACC_HEADs
where serialNos.Contains(p.NSCHEDULE_SL)
select p;
return objList;
}
}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 364
1 Nirav Prabtani 268
2 _Amy 185
3 CHill60 170
4 Sergey Alexandrovich Kryukov 166
0 OriginalGriff 8,004
1 Sergey Alexandrovich Kryukov 7,017
2 Maciej Los 4,039
3 Peter Leow 3,738
4 CHill60 2,912


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 13 Aug 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100