基本上,我一直在尝试这样做(基于两列计算不同):
select count(distinct(checksum(TableA.PropertyA, TableB.PropertyB)))
from TableA
left outer join TableB
on TableA.TableBId = TableB.Id
where PropertyA like '%123%'
一直在谷歌上搜索如何做到这一点,但没有运气。试过这个,但从未真正奏效。根据两个表中的两个属性,这并不能明确计算:
var queryOver = c.QueryOver<TableA>();
TableB tableBAlias = null;
TableA tableAAlias = null;
ProjectionList projections = Projections.ProjectionList();
queryOver.AndRestrictionOn(x => x.PropertyA).IsLike("%123%");
projections.Add(Projections.CountDistinct(() => tableAAlias.PropertyA));
queryOver.JoinAlias(x => x.TableB , () => tableBAlias, JoinType.LeftOuterJoin);
projections.Add(Projections.CountDistinct(() => tableBAlias.PropertyB));
queryOver.Select(projections);
queryOver.UnderlyingCriteria.SetProjection(projections);
return queryOver.TransformUsing(Transformers.DistinctRootEntity).RowCount();