tags:

views:

245

answers:

1

I have the following code:

criteria.SetProjection(Projections.ProjectionList()
.Add(Projections.Property("_personId")), "_ personId")
.Add(Projections.Property("_firstName"), "_firstName")
.Add(Projections.Property("_lastName"), "_lastName")
.Add(Projections.Property("_address"), "_ address ")                
.SetResultTransformer(Transformers.AliasToBean(typeof(Person)));

I get the following error: NHibernate.QueryException: property does not map to a single column: _address

_address is a component of Person in Nhibernate Mapping.

Is it possible to use Projections.Property on a component?

A: 

I don't think you could use the _address component, you'd have to use the individual column names that make up the _address component.

So somthing like

.CreateAlias("Person.Address", "Address")    
.Add(Projections.Property("_streetName"), "Address.streetOne")
lomaxx
Thanks. I added .Add(Projections.Property("_addressOne"), "_address._addressOne"). I get the error:could not resolve property: _addressOne of Person. _addressOne is a property for the Address class.
Roslyn
you might need to add a CreateAlias to your clause
lomaxx
Thanks. I have added a CreateAlias and it still does not work.
Roslyn