【发布时间】:2017-10-18 23:48:55
【问题描述】:
我问了一个 MS SQL 问题,得到了回答 >hereview 而不是表。
我现在的问题是关于对 MySQL 数据库的 EF 查询。我正在做一个非常相似的查询,但后端是 MySQL 数据库 view 而不是表。我正在尝试使用与 MS SQL 表完全相同的构造并具有:
from myView in db.companySessions
where myView.machine.ToUpper().Substring(0,
(int) SqlFunctions.CharIndex(myView.machine, "."))
.Equals(machine.ToUpper().Substring(0,
(int) SqlFunctions.CharIndex(machine.ToUpper(), ".")))
db.companySessions 指向 MySQL 数据库中的视图。
machine 是传入该方法并由该方法验证的字符串。我得到了例外:
LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String,
System.StringComparison)' method, and this method cannot be translated into
a store expression.
这是因为我要访问view 还是要访问 MySQL?
【问题讨论】:
-
如果你使用 .net Core,我敢打赌是因为 MySQL。