Hello,
I have 2 entities:
public class Authority : Entity
{
[NotNull, NotEmpty]
public virtual string Name { get; set; }
[NotNull]
public virtual AuthorityType Type { get; set; }
}
public class AuthorityType : Entity
{
[NotNull, NotEmpty]
public virtual string Name { get; set; }
public virtual string Description { get; set; }
}
Now I wish to find all authorities from repository by type. I tried doing it like this:
public IList<Authority> GetAuthoritiesByType(int id)
{
ICriteria criteria = Session.CreateCriteria(typeof (Authority));
criteria.Add(Restrictions.Eq("Type.Id", id));
IList<Authority> authorities = criteria.List<Authority>();
return authorities;
}
However, I'm getting an error that something is wrong with the SQL ("could not execute query". The innerexception is following: {"Invalid column name 'TypeFk'.\r\nInvalid column name 'TypeFk'."}
Any advice ? Any other approach ?
Best wishes, Andrew