English 中文(简体)
为什么任何具有EdmEntityTypeAttribute的类即使未使用也会导致运行时错误?
原标题:Why any class with EdmEntityTypeAttribute causes runtime error even if it s not used?

我创建了ADO.NET实体数据模型。假设它生成了以下代码:

namespace MyEntities
{
       //Contexts
       ...
       [EdmEntityTypeAttribute(NamespaceName="Entities", Name="table1")]
       [Serializable()]
       [DataContractAttribute(IsReference=true)]
       public partial class table1 : EntityObject{...}
}

对它的任何操作都很好。例如

var cxt = new SPEntities();
var res = (from t in cxt.table1
           select t).ToList();

但是,如果我在表1类的Differentique命名空间中添加了属性为[EdmEntityTypeAttribute]ANY类,但在表1类别所在的1SAME程序集中,则会出现运行时错误,如:该类型没有任何键成员“指定的架构无效。假设我添加了这个类:

 namespace ANY_NAMESPACE
    {
        [EdmEntityTypeAttribute]
        public class ANY_CLASS
        {
        }
    }

如果我甚至不使用ANY_CLASS类,为什么会出现这种错误?

看起来ADO.NET实体引擎在执行代码之前会遍历ASSEMBLY中具有[EdmEntityTypeAttribute]属性的所有类,并检查这些类的构造是否正确,即使它们没有被使用。我说得对吗?如果我这么做了,它为什么这么做?

非常感谢。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签