最近Windows SmartClientソリューションをnHibernate 2.2から4.0にアップグレードし、dbに書き込む際に例外が発生しています。'System.Collections.ArrayList'型のオブジェクトを型 'System.Collections.Generic.IEnumerable'にキャストできません
例外は、このコードでスローされます。
this.session.Save(this.Location); // NHibernate.ISession
tx.Commit(); // exception thrown here
例外は次のとおりです。
NHibernate.dll System.InvalidCastExceptionの中に 'System.InvalidCastExceptionの': 型のオブジェクトをキャストすることができません'System.Collections.ArrayList' と入力して 'System.Collections.Generic.IEnumerable`1 [System.Object]'と入力します。いくつかのタイプが指定されており、一部にはないことを
がprotected System.Collections.IList locationList; public virtual System.Collections.IList AssociatedLocationList { get { if (this.locationList == null) { this.locationList = new System.Collections.ArrayList(); } return this.locationList; } set { this.locationList = value; } } protected System.Collections.Generic.IList<Inspection> inspectionList; public virtual System.Collections.Generic.IList<Inspection> InspectionList { get { if (this.inspectionList == null) { this.inspectionList = new System.Collections.Generic.List<Inspection>(); } return this.inspectionList; } set { this.inspectionList = value; } }
注:
が保存されているオブジェクトで複数のリストがあり、ここではカップル代表的なものです。
提案の1つhereは、IList
にプロパティが設定されていますが、すでにそれを持っています。
何ができますか?
ここでジェネリック薬を使用することを検討しましたか?裸の物体の周りを投げることは非常に... 2003. –
私は元の投稿にを持つ別の代表的なプロパティを追加しました。これがないと問題を引き起こす可能性があることを示唆していますか? –
キャストはジェネリック版には存在しなくなりました。 –