[英]MVC C# Entity Framework error: the data reader is incompatible with the specified
[英]Data Reader error using Entity Framework
我正在構建使用實體SQL(實體框架)連接到SQL數據庫的WCF服務應用程序。 目前,我通過幾種方法不斷收到此錯誤:
數據讀取器具有多個字段。 多個字段對於EDM原語或枚舉類型無效。
這是其中一種方法的示例,不勝感激關於如何實現此方法的一些建議:
public string[] Tables()
{
string Sql = @"SELECT * FROM information_schema.tables";
using (var Context = new XEntities())
{
Context.Database.Connection.Open();
IEnumerable<string> Query = Context.Database.SqlQuery<string>(Sql);
string[] results = Query.ToArray();
Context.Database.Connection.Close();
return results;
}
該方法應該在數據庫中查詢表列表,然后將它們發送回數組中。 然后,Windows Phone應用程序會將其輸入到ListBox中。
感謝您的時間。
修改查詢以選擇要填充Query
的列:
string Sql = @"SELECT TABLE_NAME FROM information_schema.tables";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.