1

当我使用 fetch 时怎么办?“与”不起作用。

ISession session = NHibernateHelper.GetSession();

string sql = "FROM Filial fi " +
             "left join fetch fi.LstUsuario usr " +
             "with usr.NumSequencial = :idUsr " +
             "order by fi.Nome";

IQuery query = session.CreateQuery(sql);

query.SetParameter("idUsr", usuario.NumSequencial, NHibernateUtil.Int64);

lstFilial = (List<Filial>)query.List<Filial>();

错误消息:意外令牌:使用 [FROM Entidade.Filial fi left join fetch fi.LstUsuario usr with usr.NumSequencial = :idUsr order by fi.Nome]

SQL 中的代码

select *
from TFILIAL fi
  left join TPERMIS_USR_FILIAL usrFi
    on fi.anum_sequ_filial = usrfi.anum_sequ_filial
    and usrfi.anum_sequ_usuario = 2;

先感谢您。

4

0 回答 0