Linq to SQL 中将数字转换为字符串

 使用LINQ to Entities中的SqlFunctions调用数据库中的函数

添加引用System.Data.Entity

引用命名空间

using System.Data.Objects.SqlClient;

然后使用SqlFunctions.StringConvert即可

string ids=",1,2,3,4";
var list=db.Where(d=>ids.IndexOf(","+SqlFunctions.StringConvert(d.id)+",")>-1)

 

posted @ 2017-04-27 17:07  dotnet007cn  阅读(2419)  评论(1编辑  收藏  举报