如何创建ADO.NET实体框架ObjectContext扩展 [英] How to create ADO.NET Entity Framework ObjectContext extensions
问题描述
我想创建塞萨尔德拉托雷的博客文章.
但是我不确定如何声明包含扩展方法的类.
But I'm not sure how to declare the class that holds my extension methods.
Griff Townsend 写道:
如果我包含对此类的引用(或将类放在我的命名空间中),任何ObjectContext引用都将是能够执行这些扩展:
If I include a reference to this class (or have the class in my namespace), any ObjectContext references will be able to execute these extensions:
如果您查看上面的照片,您应该可以看到我现在可以干净地访问任何我添加到EntitySet的函数我创建的.
If you look at the tool tip in the photo above, you should be able to see that I can now cleanly access any function that I add to the EntitySet that I create.
如何声明包含扩展方法的类?
How do I declare the class that holds my extension methods?
推荐答案
您只需要声明一个静态类:
You just have to declare a static class :
public static class MyExtensions
{
// extension methods go here
}
这篇关于如何创建ADO.NET实体框架ObjectContext扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!