我正在尝试创建一个nhibernate地图。这是一个参考,但我试图使用论坛。但问题是numpernate没有使用forumula sql。
这是我的映射代码:
public void Override( AutoMapping<FixtureResult> mapping )
{
mapping.Table( "Fixture" );
mapping.References( x => x.Fixture, "Id" );
mapping.References( x => x.AwayTeamScore ).Formula( @"(SELECT TOP 1 tf.Id FROM TeamFixture tf WHERE tf.FixtureId = Id AND tf.HomeTeam = 0)" );
mapping.References(x => x.HomeTeamScore).Formula(@"(SELECT TOP 1 tf.Id FROM TeamFixture tf WHERE tf.FixtureId = Id AND tf.HomeTeam = 1)");
}
生成的sql:
SELECT this_.Id as Id15_0_,
this_.AwayTeamScoreId as AwayTeam2_15_0_,
this_.HomeTeamScoreId as HomeTeam3_15_0_
FROM Fixture this_
我做错了什么因为我很困惑为什么nhibernate没有使用我的论坛。