[英]The type '<>f__AnonymousType1`2[System.String,System.Data.Linq.Binary]' must declare a default (parameterless) constructor
I'm getting the exception 我得到了例外
System.InvalidOperationException: The type '<>f__AnonymousType1`2[System.String,System.Data.Linq.Binary]' must declare a default (parameterless) constructor in order to be constructed during mapping. System.InvalidOperationException:类型'<> f__AnonymousType1`2 [System.String,System.Data.Linq.Binary]'必须声明一个默认(无参数)构造函数,以便在映射期间进行构造。
when I try run 当我尝试跑步
await cmd.ExecuteReaderAsync();
a very simple command that returns rows from a table that contains a rowversion ( timestamp, not null
) column. 一个非常简单的命令,该命令从包含rowversion( timestamp, not null
)列的表中返回行。 Any idea why? 知道为什么吗? Very strange. 很奇怪。
EDIT: 编辑:
It's actually failing when I run 当我跑步时实际上是失败的
return this.Translate<T>(reader);
directly afterwards. 之后直接。
You are getting this error because you are trying to translate your reader in the type that does not have default constructor. 之所以出现此错误,是因为您试图以没有默认构造函数的类型来翻译您的阅读器。 That means you have defined your own constructor in the type which overrides the default parameterless constructor. 这意味着您已经用覆盖默认无参数构造函数的类型定义了自己的构造函数。
Simple define the parameter less constructor in the Type in which you are trying to translate the reader object and you are done. 只需在尝试转换阅读器对象的Type中定义参数较少的构造函数即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.