【发布时间】:2019-01-03 17:39:00
【问题描述】:
我只是不够熟悉,还不知道为什么会发生这种情况。不知道我错过了什么。我可以使用一些帮助,因为我使用的教程似乎没有遇到同样的问题......
public class CustomerRepository
{
public List<Customers> GetCustomers()
{
var db = new e21testEntities();
var Customers = db.orderfrom
.OrderBy(x => x.bus_name)
.ToList();
return Customers;
}
}
客户不会返回错误
不能隐式转换类型
System.Collections.Generic.List<NestedGrid.orderfrom>到System.Collections.Generic.List<NestedGrid.Customers>
【问题讨论】:
-
Customers 是否也是您的某一类的名称?
-
db.orderfrom听起来不应该是Customers对象的集合... -
您还应该在
<>中使用正确的部分重新输入错误。您还需要将其标记为代码,方法是将其包含在 "``" 中,这样它就不会尝试将<>中的内容视为标记。 -
orderfrom 是 e21testEntities 模型中的表名。我不确定开发人员为什么要这样命名它,但它确实包含所有客户记录。整个错误是“无法将类型'System.Collections.Generic.List
'隐式转换为System.Collections.Generic.List ' -
然后更新您的问题以显示确切的错误消息。