如何在Nhibernate中加入两个表
List olist = null; olist = (_session.CreateQuery("Select pc.Id as Id,pct.DescEn as DescEn,pct.DescAr as DescAr,pc.ContentEn as ContentEn,pc.ContentAr as ContentAr from ProjectCharter pc,ProjectCharterTemplate pct where pct.Id=pc.PRC_PCT_ID and pc.PRC_PRJ_ID=1").List()).ToList();
这是我的查询,我想加入两个表并得到一个输出,当我运行这是db我得到完美的回答,但当我通过c#与nhibernate映射运行它。 我得到错误。
我可以这样查询,还是有任何其他方法来连接两个表。
提前致谢。
这很简单。 非常容易。 检查
所以,QueryOver中的上述查询可能如下所示:
上述就是C#学习教程:如何在Nhibernate中加入两个表分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
// alias for later use ProjectCharter project = null; ProjectCharterTemplate template = null; var list = session .QueryOver(() => project) // the JOIN will replace the WHERE in the CROSS JOIN above // it will be injected by NHibernate based on the mapping // relation project has many-to-one template .JoinQueryOver(c => c.Templates, () => template) .Select( // select some project properties _ => project.ContentEnglish, ... // select some template properties _ => template.DescriptionEnglish, ) .List
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/951467.html