我問了一個MS SQL問題,回答了>here <。這是一個後續問題。本質上它是相同的,除了數據庫是MySQL而不是MS SQL,並且LINQ查詢的對象是view
而不是表。後續到:C#Linq字符串與索引比較
我現在的問題是關於對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的核心我敢打賭,這是因爲MySQL。 – Nikolaus