如何使用nhibernate ConfORM连接来自不同数据库的两个表,或者至少在nhibernate ConfORM中编写sql查询?
这是我需要运行的查询:
select RTRIM(l.descr) as affiliation, a.LocationId
from Facilities a
join [tmt-sam2].sammi.dbo.location l ON a.LocationId = l.off_code+'-'+l.location谢谢,阿列克谢
发布于 2011-10-21 14:54:26
如果你没有那么多的位置,你可以直接加载所有
using (var session1 = sessionfactoryDataBase1.OpenSession())
using (var session2 = sessionfactory_tmt_sam2.OpenSession())
{
var locations = session2.QueryOver<Location>().List();
var results = session1.QueryOver<Facility>()
.Where(f => f.LocationId.IsIn(locations.Select(l => l.OffCode + '-' + l.location)))
.AsEnumerable()
.Join(locations, f => f.LocationId, l => l.OffCode + '-' + l.location, (f, l) => new { Description = l.descr.TrimEnd(), LocationId = f.LocationId });
}否则,代码中的批处理
https://stackoverflow.com/questions/7839237
复制相似问题