将班级id以字符串形式输入如:“1111,1112,1113”。
数据库里的id为int型,
在数据路里找到匹配的相应班级转换成列表。
在这里爆出问题:不识别方法"System.String ToString()",跪求大神提出解决方案。
public IEnumerable<Class1> FindClassesByIDs(string ids)
        {
            var r = from c in this.DbContext.Class1
                    where ids.IndexOf(c.Class1ID.ToString()) >= 0
                    select c;
            return r.ToList();
        }

方法1: 字符串数组转整形数组  然后用contains

string str=“1111,1112,1113”;
string[] strArray =str.Split(new char[]{ ',' });
int[] intArray;

intArray = Array.ConvertAll<string, int>(strArray, s => int.Parse(s));
var r = from c in this.DbContext.Class1
                    where c.Class1ID    in    intArray   select c;

方法2:  同一种方法

var strids= ids.Split(',');
            int []intids=new int[strids.Length];
            for (int i = 0; i < strids.Length; i++)
            {
                intids[i] =int.Parse(strids[i]);
            }
         intids.contain(.......)

linq to entity不识别方法"System.String ToString()"的更多相关文章

  1. Linq中字段数据类型转换问题(Linq to entity,LINQ to Entities 不识别方法"System.String ToString()"问题解决)

    1.在工作中碰到这样一个问题: 使用linq时,需要查询两个表,在这两张表中关联字段分别是int,和varchar()也就是string,在linq中对这两个字段进行关联, 如果强制类型转换两个不同类 ...

  2. LINQ to Entities 不识别方法"System.String ToString()",因此该方法无法转换为存储表达式 的解决方法

    一.案例1,及解决方案: "LINQ to Entities 不识别方法"System.String ToString()",因此该方法无法转换为存储表达式." ...

  3. LINQ to Entities 不识别方法“System.String ToString()”,因此该方法无法转换为存储表达式。

    var data = DataSource.Skip(iDisplayStart).Take(iDisplayLength).Select(o => new { MatNR = o.MatNR, ...

  4. LINQ to Entities 不识别方法“System.String ToString(System.String)”,因此该方法无法转换为存储表达式。

    来源:https://www.cnblogs.com/hao-1234-1234/p/9112434.html 6  Select的时候,时间无法转换成 年月日  YYMMMdd 报错:LINQ to ...

  5. LinQ to entities 不能识别方法“system.string.ToString(system.String)”.因此该方法无法转换为存储表达式

    [我也是刚研究IEnumerable和IQueryable]以下都是个人理解,仅供参考,如有错误欢迎指出~ 在EF里面,使用IQueryable和IEnumerable可以延迟加载. IQueryba ...

  6. LINQ to Entities 不识别方法“System.String ToString(“yyyy-MM-dd”)”

    将Queryable转化为IEnumerable或者直接Tolist()

  7. LINQ to Entities 不识别方法“System.String get_Item(Int32)”,因此该方法无法转换为存储表达式。

    1.LINQ to Entities 不识别方法“System.String get_Item(Int32)”,因此该方法无法转换为存储表达式.项目中发现linq to entities 不识别? , ...

  8. LINQ to Entities 不识别方法“System.Guid Parse(System.String)”,因此该方法无法转换为存储表达式。

    LINQ to Entities 不识别方法"System.Guid Parse(System.String)",因此该方法无法转换为存储表达式. linq 中不能转换类型

  9. LINQ to Entities 不识别方法“System.DateTime AddDays(Double)

    今天本想在linq里按照时间筛选一下超时的数据,一共两个字段FeedBackTime(计划反馈时间).EndTime(实际反馈时间).需求是这样的,查找数据库里所有EndTime大于FeedBackT ...

随机推荐

  1. PyQt(Python+Qt)学习随笔:信号签名(signature of the signal)是什么?

    老猿Python博文目录 专栏:使用PyQt开发图形界面Python应用 老猿Python博客地址 1.概念解释 函数签名:由函数的参数个数与其类型组成.函数在重载时,利用函数签名的不同即参数个数与类 ...

  2. [BJDCTF 2nd]Schrödinger && [BJDCTF2020]ZJCTF,不过如此

    [BJDCTF 2nd]Schrödinger 点进题目之后是一堆英文,英语不好就不配打CTF了吗(流泪) 复制这一堆英文去谷歌翻译的时候发现隐藏文字 移除test.php文件,访问test.php ...

  3. js onreadystatechange 和 onload的区别

    IE的script 元素只支持onreadystatechange事件,不支持onload事件. FF的script 元素不支持onreadystatechange事件,只支持onload事件. 如果 ...

  4. 数据结构—— Trie (前缀树)

    实现一个 Trie (前缀树),包含 插入, 查询, 和 查询前缀这三个操作. Trie trie = new Trie(); trie.insert("apple"); trie ...

  5. oracle 时间段查询

    <select id="selectByRzrq" resultMap="BaseResultMap" parameterType="java. ...

  6. J20航模遥控器开源项目系列教程(六)亚克力外壳制作

    我们的开源宗旨:自由 协调 开放 合作 共享 拥抱开源,丰富国内开源生态,开展多人运动,欢迎加入我们哈~ 和一群志同道合的人,做自己所热爱的事! 项目开源地址:https://github.com/J ...

  7. STL——容器(List)list 的大小操作

    ist.size(); //返回容器中元素的个数 1 #include <iostream> 2 #include <list> 3 4 using namespace std ...

  8. postgresql 运行sql文件

    方法一: [postgres@node01 ~]$ psql -Upostgres postgres=# \l List of databases Name | Owner | Encoding | ...

  9. RMAN duplicate from active database

    在Oracle 11G有二种方法实现duplicate: 1.Active database duplication 2.Backup-based duplication Active databas ...

  10. ElasticSearch中head插件的简单用法

    1.首先在左侧打开Query栏. 2.Query下方的第一栏是分别输入es的地址.端口号.index.type. 3.Query下方的第二栏是输入将要执行的方式,旁边的下拉框是辅助选择执行的类型,如图 ...