【问题标题】:Data Reader error using Entity Framework使用实体框架的数据读取器错误
【发布时间】:2014-03-27 00:25:59
【问题描述】:

我正在构建一个 WCF 服务应用程序,它使用实体 SQL(实体框架)连接到 SQL 数据库。目前,我通过多种方法不断收到此错误:

数据读取器有多个字段。多个字段对 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。

感谢您的宝贵时间。

【问题讨论】:

    标签: c# sql wcf entity-framework windows-phone-7


    【解决方案1】:

    修改您的查询以选择要填充 Query 的列:

    string Sql = @"SELECT TABLE_NAME FROM information_schema.tables";
    

    【讨论】:

      猜你喜欢
      • 2023-03-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-23
      • 1970-01-01
      • 1970-01-01
      • 2014-08-08
      • 1970-01-01
      相关资源
      最近更新 更多