[英]Cannot be used as type parameter 'TElement' in the generic type or method
I am using Entity Model, C#, .NET Framework 3.5.我正在使用实体 Model、C#、.NET 框架 3.5。 I have generated entity classes from POCO , but it had issues on ObjectSet and CreateObjectSet which I fixed by replacing them with ObjectQuery and CreateQuery.
我已经从POCO生成了实体类,但它在 ObjectSet 和 CreateObjectSet 上有问题,我通过用 ObjectQuery 和 CreateQuery 替换它们来修复它们。
But I still have one issue in following code in EntityGenerator.Context.cs
,但是我在
EntityGenerator.Context.cs
中的以下代码仍然存在一个问题,
The code is代码是
public ObjectResult<lead> GetLeads()
{
**return base.ExecuteFunction<lead>("GetLeads");**
}
And the error is错误是
Proj.EntityModel.employee cannot be used as type parameter 'TElement' in the generic type or method 'System.Data.Objects.ObjectContext.ExecuteFunction(string, params System.Data.Objects.ObjectParameter[])'.
Proj.EntityModel.employee 不能用作泛型类型或方法“System.Data.Objects.ObjectContext.ExecuteFunction(string, params System.Data.Objects.ObjectParameter[])”中的类型参数“TElement”。 There is no implicit reference conversion from 'Proj.EntityModel.employee' to 'System.Data.Objects.DataClasses.IEntityWithChangeTracker'.
没有从“Proj.EntityModel.employee”到“System.Data.Objects.DataClasses.IEntityWithChangeTracker”的隐式引用转换。
What's this error?这是什么错误? What's solution?
有什么解决办法?
It sounds like you just need to make employee
implement IEntityWithChangeTracker
.听起来您只需要让
employee
实现IEntityWithChangeTracker
。
(I suspect you've cut and paste the wrong section of code though, given that the error talks about employee
and your code talks about lead
. I'd also encourage you to change your names so that they follow .NET naming conventions.) (我怀疑您剪切并粘贴了错误的代码部分,因为错误涉及
employee
,而您的代码涉及lead
。我还鼓励您更改名称,以便它们遵循 .NET 命名约定。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.