我的代碼:投與linqToEntity(ESQL)
public List<Book> GetBook(string NameField, object Value)
{
var queryESQL = @"select VALUE Book from Book
where Cast(Book." + NameField + " as string) like '%M%'";
var query = this.Entities.CreateQuery<Book>(
queryESQL);
return query.ToList();
}
錯誤:
類型 '串' 無法找到。確保加載了所需的模式 ,並且正確導入了名稱空間。近類型 名,行2,列51
更新:
新代碼:
public List<Book> GetBook(string NameField, object Value)
{
var queryESQL = @"select VALUE Book from Book
where Cast(Book." + NameField + " as EDM.string) like '%M%'";
var query = this.Entities.CreateQuery<Book>(
queryESQL);
return query.ToList();
}
錯誤:
Type 'EDM.string' could not be found. Make sure that the required schemas are loaded and that the namespaces are imported correctly. Near type name, line 2, column 51.
錯誤:無法找到類型'EDM.string'。確保已加載所需的模式並正確導入名稱空間。靠近類型名稱,第2行,第51列。 – mrJack
@mrJack:你確定在'EDM.String'中大寫了'S'嗎? – StriplingWarrior
@StriplingWarrior:是的,我相信 – mrJack