NHibernate error: could not resolve property

Hi,

I am trying to get a list aplying more than one field to the ordering. I want to do this by using criteria because I need control on first and max results and I do not want to work with query expressions.

I have the following code but it returns this error: “NHibernate error: could not resolve property:clsAffiliate.Names of :padronData.clsAffiliate”

Dim oCriteria As clsAffiliateCriteria = New clsAffiliateCriteria()
oCriteria.AddOrder(New NHibernate.Expression.Order("clsAffiliate.names", True))
oCriteria.AddOrder(New NHibernate.Expression.Order("clsAffiliate.FatherLastName", True))
oCriteria.AddOrder(New NHibernate.Expression.Order("clsAffiliate.MotherLastName", True))
Dim oAffiliates As clsAffiliate() = oCriteria.ListClsAffiliate

The corresponding mapping file is like this:

<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
	<class name="padronData.clsAffiliate, PadronData" table="pdnAffiliates" lazy="false">
		<id name="UID" column="UID" type="Int32" unsaved-value="0">
			<generator class="identity">
			</generator>
		</id>
		<property name="Names" column="names" type="String" length="35" not-null="true"/>
		...
	</class>
</hibernate-mapping>

I have tried to add the Order expression with property names like:

  • “names”
  • “clsAffiliate.names”
  • “padronData.clsAffiliate.names”
  • “pdnAffiliates.names”"

and with the property name uppercased like:

  • “Names”
  • “clsAffiliate.Names”
  • “padronData.clsAffiliate.Names”
  • “pdnAffiliates.Names”"

What am I doing wrong?

Thanks in advance for your help.

Victor Marquez

Hello Victor,

Please try:
Dim oCriteria As clsAffiliateCriteria = New clsAffiliateCriteria()
oCriteria.Names.Order(True)
oCriteria.FatherLastName.Order(True)
oCriteria.MotherLastName.Order(True)
Dim oAffiliates As clsAffiliate() = oCriteria.ListClsAffiliate

Best regards,
Jick

Hi Jick!!!

It should have been pretty obvious :oops:

Works perfectly!

Thanks a lot.

Regards

Victor Marquez

Hi Victor,

Our pleasure. Feel free to post again if there are any other questions.

Have a nice weekend!

Best regards,
Jick