I seem to get an error when querying an object that has a child POCO property object:
could not resolve property: PreferredLanguage.Name of: AcademyData.Entities.StudentsInformation
My query:
Session.QueryOver<StudentsInformation>().Where(x => x.Active == 1 && x.PreferredLanguage.Name == firstName).List()
If I remove the x.PreferredLanguage.Name criteria, it works, and I see the correct Name value of the object, but it won’t let me use it as a query. What am I doing wrong?
Here is my mapping:
References(x => x.PreferredLanguage).Column("PreferredLanguageID");
Also, I’ve split my POCO’s and mappings into 2 seperate assemblies, if that makes any difference. I configure the mapping so:
.Mappings(x => x.FluentMappings.AddFromAssemblyOf<AcademyData.Dummy>().AddFromAssemblyOf<data.core.Dummy>())
Ignore the dummy, was using it to test something.
EDIT: I’ve tested it using an entity from the same assembly and the problem still exists.
EDIT:
I found a solution to my problem:
return SessionManager.Session.QueryOver<StudentsInformation>().JoinQueryOver<PersonBase>(s => s.Person).Where(p => p.FirstName == firstName).List();
Is this the right way of doing it, or should I still be able to do it without the JoinQueryOver for a different table?
Alternatively, you can use LINQ instead of QueryOver: