sergey wrote:
Please post details.
Thanks for reply.
Please find the details below:
This is nhibernate file (for Project class):
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="MySample.BusinessObjects.Project, MySample.BusinessObjects" table="Project">
<id name="ProjectID" type="Int32" unsaved-value="0">
<column name="ProjectID" sql-type="int" not-null="true" unique="true" index="PK_Project"/>
<generator class="native" />
</id>
<property name="Name" type="String">
<column name="Name" length="255" sql-type="varchar" not-null="false"/>
</property>
<property name="Description" type="String">
<column name="Description" length="2147483647" sql-type="text" not-null="false"/>
</property>
<property name="StartDate" type="DateTime">
<column name="StartDate" sql-type="datetime" not-null="false"/>
</property>
<property name="EndDate" type="DateTime">
<column name="EndDate" sql-type="datetime" not-null="false"/>
</property>
<property name="Effort" type="Decimal">
<column name="Effort" sql-type="decimal" not-null="false"/>
</property>
</class>
</hibernate-mapping>
This is method for retrieving integer value (It is NHibernate wrapper - Portal):
Code:
public int RetrieveInt(string queryString)
{
IList list = m_Session.Find(queryString);
return (int)list[0];
}
This is a test method:
Code:
[TestMethod]
public void Min()
{
Project project = Project.Create();
project.Name = "This is name";
project.Description = "This is description";
project.Effort = 10;
project.StartDate = DateTime.Now;
project.EndDate = DateTime.Now.AddMonths(1);
portal.Save(project);
Project projectDouble = Project.Create();
projectDouble.Name = "This is name 2";
projectDouble.Description = "This is description 2";
projectDouble.Effort = 15;
projectDouble.StartDate = DateTime.Now;
projectDouble.EndDate = DateTime.Now.AddMonths(1);
Project.Save(projectDouble);
Assert.AreEqual(project.ProjectID, Portal.Instance.RetrieveInt("select min(Project.ProjectId) from Project"));
}
The method above gives the following exception:
Code:
Test method MySample.BusinessObjects.Test.ModelTest.Min threw exception: System.InvalidCastException: Specified cast is not valid.
The debug shows that the following line
Code:
IList list = m_Session.Find(queryString);
of RetrieveInt code gives the list of 2 elements, in other words the
Code:
m_Session.Find("select min(Project.ProjectId) from Project")
returns the list of all project's entities in database's table [Project].
And also one more question using the moment. When do you plan to full support .NET 2.0 (if you plan it :D )?
Looking forward to hearing from you.