Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# NHibernate:[PropertyAccessException:无效强制转换(检查映射是否存在属性类型不匹配)_C#_Asp.net_Nhibernate - Fatal编程技术网

C# NHibernate:[PropertyAccessException:无效强制转换(检查映射是否存在属性类型不匹配)

C# NHibernate:[PropertyAccessException:无效强制转换(检查映射是否存在属性类型不匹配),c#,asp.net,nhibernate,C#,Asp.net,Nhibernate,这是我尝试运行此代码时遇到的错误: Icriteria critBKCP = sess.CreateCriteria(typeof(BklCustomerProduct)); IList<BklCustomerProduct> objBklCustomerProducts = critBKCP.List<BklCustomerProduct>(); 我对该部分的映射如下所示: <property column="datemodif" type="DateTim

这是我尝试运行此代码时遇到的错误:

Icriteria critBKCP = sess.CreateCriteria(typeof(BklCustomerProduct));

IList<BklCustomerProduct> objBklCustomerProducts = critBKCP.List<BklCustomerProduct>();
我对该部分的映射如下所示:

 <property column="datemodif" type="DateTime" name="Datemodif" />


如果有人能帮助我,我将不胜感激。

在您的映射中尝试以下方法:

<property column="datemodif" type="System.Nullable`1[[System.DateTime, mscorlib]], mscorlib" name="Datemodif" />


您正在定义映射中的类型是datetime。但是,该类型是可为空的datetime。忽略映射定义中的类型规范。Nhibernate可以自己找到它。

修改后的行现在看起来是这样的:
。并且仍然抛出相同的错误。因此,问题不在于此属性。任何提示我应该查看吗?在内部异常中,可能会显示什么属性是错误的Mapped这是我第一次查看的位置,但是InnerException只是{specified cast is not valid}和null。没有任何地方说明映射时哪个类生成此错误?
<property column="datemodif" type="System.Nullable`1[[System.DateTime, mscorlib]], mscorlib" name="Datemodif" />