What controls the way the IList results properties are positionally ordered?
A quickwatch of of people shows an array of Person types. The order of the elements are in the type are:
age
Age
loginId
LoginId
name
Name
sex
Sex
Why are they in alphabetic order and not in the order of the Person.cs class?
When I bind people to a DataGridView the columns are in this order:
Sex, Name, Age, Login Id
The sql db table column order is LogonId, Name, Age, Sex as is the order of the Person.cs below?
I'd like to see the quickwatch in the order the properties appear in the class.
How can I control the order the results appear in?
IList people = session.GetNamedQuery("spPerson")
.SetMaxResults(50)
.List();
ListPeopleDataGridView.DataSource = people;
using System;
namespace NHibernate.Examples.QuickStart
{
public class Person
{
private string logonId;
private string name;
private string age;
private string sex;
public Person()
{
}
public virtual string LogonId
{
get { return logonId; }
set { logonId = value; }
}
public virtual string Name
{
get { return name; }
set { name = value; }
}
public virtual string Age
{
get { return age; }
set { age = value; }
}
public virtual string Sex
{
get { return sex; }
set { sex = value; }
}
public override bool Equals(object obj)
{
return base.Equals(obj);
}
public override int GetHashCode()
{
return base.GetHashCode();
}
}
}
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="NHibernate.Examples.QuickStart.Person, NHibernate.Examples" table="person">
<composite-id access="field">
<key-property name="LogonId" column="LogonId" type="String" length="10"/>
<key-property name="Name" column="Name" type="String" length="40" />
</composite-id>
<property name="Age" type="String" length="10"/>
<property name="Sex" type="String" length="1"/>
</class>
<sql-query name="spPerson">
<return alias="person" class="NHibernate.Examples.QuickStart.Person, NHibernate.Examples" />
SELECT * FROM person
</sql-query>
</hibernate-mapping>
|