linq to SQL link 和in 操作

直接上代码:一看就懂

 

var query = from c in ctx.Customers

where c.City == "London"

select c;,

 

var query = from c in ctx.Customers

where c.City.StartsWith("Lo")

select c;

 

var query = from c in ctx.Customers

where c.City.StartsWith("L") && c.City.Contains("n")

select c;

 

var query = from c in ctx.Customers

where SqlMethods.Like(c.City, "L_n%")

select c;

 

相当于SQL语句中的 where 字段名 in()

 

var ids ={1,2,3};


var query =from item in context.items
            where ids
.Contains( item.id )
           
select item;

 

 

var result = from col in dt.AsEnumerable() where (new string[] { "Save", "Revocation", "Auditing", "EndAudit" }).Contains(col[name]) select col[name];

posted @ 2012-06-08 14:32  (二少)在南极  阅读(1223)  评论(0编辑  收藏  举报