[英]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.