简体   繁体   English

使用实体框架的数据读取器错误

[英]Data Reader error using Entity Framework

I'm in the process of building a WCF Service Application which connects to an SQL Database using Entity SQL (Entity Framework). 我正在构建使用实体SQL(实体框架)连接到SQL数据库的WCF服务应用程序。 At the moment I keep getting this error with several methods: 目前,我通过几种方法不断收到此错误:

The data reader has more than one field. 数据读取器具有多个字段。 Multiple fields are not valid for EDM primitive or enumeration types. 多个字段对于EDM原语或枚举类型无效。

This is an example of one of the methods and would appreciate some advice on how to approach this: 这是其中一种方法的示例,不胜感激关于如何实现此方法的一些建议:

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;

        }

The method is supposed to query the database for a list of tables and send them back in an array. 该方法应该在数据库中查询表列表,然后将它们发送回数组中。 This will then be inputted into a ListBox by the Windows Phone App. 然后,Windows Phone应用程序会将其输入到ListBox中。

Thank You for your time. 感谢您的时间。

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MVC C#实体框架错误:数据读取器与指定的版本不兼容 - MVC C# Entity Framework error: the data reader is incompatible with the specified 实体框架中的“数据读取器有多个字段”错误 - “The data reader has more than one field” error in Entity Framework 具有线程的Entity Framework 6.0数据读取器 - Entity Framework 6.0 Data reader with threading 数据读取器与指定的实体框架不兼容 - The data reader is incompatible with the specified Entity Framework 实体框架返回错误-商店数据提供者返回的数据读取器没有足够的列 - Entity Framework Return error - data reader returned by the store data provider does not have enough columns 带有SQLite错误的实体框架:从商店提供商的数据读取器读取时发生错误 - Entity Framework with SQLite Error: An error occurred while reading from the store provider's data reader 从数据库生成实体框架模型时,数据读取器出现不兼容的错误 - Data reader incompatiable error when Entity Framework model generated from a database 使用实体框架的数据访问MVC中的错误 - error in Data access mvc using entity framework 实体框架:数据读取器与指定的“ NPAModel.NPAAddApplication”不兼容。 - Entity Framework: The data reader is incompatible with the specified 'NPAModel.NPAAddApplication'. 使用实体框架数据不匹配 - Using Entity Framework data mismatch
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM