您的位置:首页 > 数据库

linq to SQL link 和in 操作

2012-06-08 14:32 411 查看
直接上代码:一看就懂

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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: