Hi,
I am using Nhibernate to retrieve data from database and pass the data to UI throw WCF, the retrieval of data from database works fine and when returning the data from WCF to UI i get the following error
The underlying connection was closed: The connection was closed unexpectedly.
Billow is the code i am using.
Code:
[DataContract]
public class Patient
{
[DataMember]
public virtual string DocId { get; set; }
[DataMember]
public virtual string FirstName
{
get;
set;
}
[DataMember]
public virtual string MiddleName
{
get;
set;
}
[DataMember]
public virtual string LastName
{
get;
set;
}
[DataMember]
public virtual Academic Academic
{
get;
set;
}
}
[DataContract]
public class Academic
{
[DataMember]
public virtual string Code
{
get;
set;
}
[DataMember]
public virtual string Name
{
get;
set;
}
}
This is the mapping i am using
Code:
<class name="MyProject.Patient, MyProject" table="PATIENTS" >
<id name="DocId" column="DOCID" unsaved-value="0">
<generator class="assigned" />
</id>
<property name ="FirstName" column="PATIENTFIRSTNAME"/>
<property name ="MiddleName" column="PATIENTMIDDLENAME"/>
<property name ="LastName" column="PATIENTLASTNAME"/>
<many-to-one name="Academic" class="MyProject.Academic, MyProject" column="PATIENTEDUCATIONCODE" />
</class>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="MyProject.Academic, MyProject" table="Academics" >
<id name="Code" column="ACADEMICCODE" unsaved-value="0">
<generator class="assigned" />
</id>
<property name="Name" column="ACADEMICNAME" />
</class>
</hibernate-mapping>
The above code works fine if i don't use the many-to-one mapping to academic. but when i use this mapping ore any other mapping with relations i get the error,
The underlying connection was closed: The connection was closed unexpectedly.
I am new to NHibernate is there any thing i am missing.
Thanks
Arvind