NHibernate Invalid index N for this SqlParameterCollection with Count=N Exception 簡(jiǎn)易處理
Demo Mapping Config:
2 <id name="BaseId">
3 <generator class="native"/>
4 </id>
5 <!--<discriminator column="SubType" type="String"/>-->
6 <property name="Name" column="Name" type="String" />
7 <property name="SubType" column="SubType" type="String" />
8 <property name="BaseIrType" column="IrType" type="String"/>
9
10 <any name="SubObj" meta-type="string" id-type="Int32" cascade="all">
11 <meta-value value="People" class="Person"/>
12 <meta-value value="Company" class="Company"/>
13 <column name="SubType" />
14 <column name="SubId"/>
15 </any>
16 </class>
當(dāng)我插入數(shù)據(jù)的時(shí)候會(huì)報(bào)如下錯(cuò)誤 :
當(dāng)我在插入數(shù)據(jù)的時(shí)候會(huì)報(bào)如下錯(cuò)誤 :
NHibernate: INSERT INTO People (FirstName, IrType) VALUES (@p0, @p1); select SCOPE_IDENTITY();@p0 = 'Cheng', @p1 = '0000AA'
TestCase 'NHDemo.Test.NHibernateSampleFixture.GetCustomerByIdTest'
failed: System.IndexOutOfRangeException : Invalid index 4 for this SqlParameterCollection with Count=4.
at System.Data.SqlClient.SqlParameterCollection.RangeCheck(Int32 index)
at System.Data.SqlClient.SqlParameterCollection.GetParameter(Int32 index)
at System.Data.Common.DbParameterCollection.System.Collections.IList.get_Item(Int32 index)
此處異常顯示: N = 4, 那就是配置文件的第4行有問(wèn)題, 可以簡(jiǎn)單的先注釋第4行做測(cè)試.
這里只啟一個(gè)開(kāi)頭的作用, 具體的錯(cuò)誤,根據(jù)自己的實(shí)際情況來(lái)解決.
浙公網(wǎng)安備 33010602011771號(hào)