通过函数实现,传Industry和1,分割Industry,存在返回true

解决方案 »

  1.   

    你什么数据库啊?access:
    try:
    string sql="select * from tb where instr(','+[Industry]+',','1')>0"mssql改用charindex
      

  2.   

    改一下:
    (mssql)
    select * from tb where charindex(',1,',','+Industry+',')>0
      

  3.   

    string temp = "1";
                List<Model.a3> a3s = con.a3.Where(c => (c.Industry.StartsWith(temp + ",") || c.Industry.EndsWith("," + temp) || c.Industry.Contains("," + temp + ","))).ToList();
    这样就能得出你想要的效果了
      

  4.   


     IEnumerable<Hello> BindByLinq(string input)
        {        var q = (from h in context.Hello
                     select h).ToList().Where(o => o.Industry.Split(new char[] { ',' }).Contains(input) == true);
            return q;
        }
      

  5.   


     GridView1.DataSource = BindByLinq(TextBox1.Text);
            GridView1.DataBind();
      

  6.   

    from c in context.Table where c.Industry.Silpt(',').Contains("1") select c;看看这个是不是你先要的。将这个字段分割判断就可以了,和8楼的基本类似,他用的是lamda表达式
      

  7.   

    10楼的是错的代码会有异常。并且你的Split写错了。异常为:类型“System.String[]”不支持比较运算符。
    8楼的是从数据库中查询出来再查询一到。如果数据量大的话。再查寻一到会影响效率。