I was wondering how one might go about querying a custom UserType in
Nhibernate.Linq. I get an error NHibernate.QueryException: not an
association: Term. whenever I try to query with linq.
Here is an abbreviated version of my class
I have a custom user type for my class TermCode
public class Section{
private string crn;
private TermCode Term
...
public virtual string Crn
{
get { return crn; }
set { crn = value; }
}
public virtual Termcode Term
{
get { return term; }
set { term = value; }
}
}
here is the mapping (need to use composite-id because of legacy
system)
<class name="Section" schema="Sample" table="Section">
<composite-id>
<key-property name="Crn" column="Crn" />
<key-property name="Term" column="TermCode"
type="TermCodeUserType,Sample" />
</composite-id>
</class>
This works
NHibernateManager.GetSession()
.CreateCriteria(typeof(Section))
.Add(Restrictions.Eq("SubjectCode", subjectCode))
.Add(Restrictions.Gt("Term", term))
.List<Section>();
this generates an error
(from section in NHibernateManager.GetSession().Linq<Section>()
where section.SubjectCode == subjectCode
&& section.Term >= term
select section).ToList<Section>();
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---