c# - NHibernate mapping index out of range -
c# - NHibernate mapping index out of range -
i have 2 classes:
public class carmodel { public virtual int id { get; set; } public virtual string model_name { get; set; } } and
public class transport { public virtual int id { get; set; } public virtual string lic_plate { get; set; } public virtual int model { get; set; } public virtual string odometer { get; set; } public virtual string moto_val { get; set; } public virtual class.carmodel modelis { get; set; } } and mapping:
<?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" assembly="web_nt" namespace="web_nt.models"> <class name="transport" table="transport" dynamic-update="true" lazy="false"> <id name="id" column="id" type="int"> <generator class="native" /> </id> <property name="lic_plate" /> <property name="model" /> <property name="odometer" /> <property name="moto_val" /> <many-to-one name="modelis" column="model" cascade="none" class="web_nt.models.class.carmodel" lazy="false" /> </class> <class name="web_nt.models.class.carmodel" table="car_model"> <id name="id" column="id" type="int"> <generator class="native" /> </id> <property name="model_name" /> </class> </hibernate-mapping> and exception when seek send values database(in view works perfectly): + $exception {"index out of range. must non-negative , less size of collection.\r\nparameter name: index"} system.exception {system.argumentoutofrangeexception}
and can't find might wrong here?
the issue here in doubled column mapping:
<property name="model" /> <many-to-one name="modelis" column="model" cascade="none" class="web_nt.models.class.carmodel" lazy="false" /> both properties (valuetype , reference) targeting same column. possible not write operations. have create 1 of them readonly using insert="false" , update="false"
<property name="model" insert="false" update="false" /> <many-to-one name="modelis" column="model" cascade="none" class="web_nt.models.class.carmodel" lazy="false" /> so, have access both properties, mapped same column, insert, update target column once. because original issue here: ...ndex out of range. must non-negative , less size of collection...
also check similar issue: http://stackoverflow.com/a/24248912/1679310
c# asp.net nhibernate
Comments
Post a Comment