我遇到以下错误:在from子句中多次指定了关联名称'accountali4 _'。。我在C#中使用Fluent Nhibernate。
有人知道如何解决吗?谢谢
仅当我加入“ SwiftCommonData”时才会发生此错误
编辑:添加更多信息。 Mt942Message是TypedMessage的子类,我注意到与她的任何连接都会引发异常。
FxSwiftMessage swiftAlias = null;
BasicHeaderBlock basicHeaderAlias = null;
ApplicationHeaderBlock appHeaderAlias = null;
Mt942Message typedAlias = null;
SwiftCommonData accountAlias = null;
return CurrentSession.QueryOver<FxSwiftMessage>(() => swiftAlias)
.JoinAlias(() => swiftAlias.BasicHeader, () => basicHeaderAlias)
.JoinAlias(() => swiftAlias.ApplicationHeader, () => appHeaderAlias)
.JoinAlias(() => swiftAlias.Text.TypedMessage, () => typedAlias)
//.JoinAlias(() => typedAlias.AccountIdentification, () => accountAlias)
.Where(() => typedAlias.GetType() == typeof(Mt942Message))
.And(() => ((DateTime)appHeaderAlias.InputDate).Date == referenceDate)
.And(() => basicHeaderAlias.LogicalTerminalAddress.IsLike(bicRecipient, MatchMode.Start))
.And(() => appHeaderAlias.RecipientsBic.IsLike(bicSender, MatchMode.Start))
.And(() => swiftAlias.Process == false)
//.And(() => accountAlias.Data == account)
.TransformUsing(Transformers.DistinctRootEntity)
.List<FxSwiftMessage>();
这里是Fluent Nhibernate生成的SQL,是“ accountali4_”的四倍。
FROM TB_BTG_SWIFT_MESSAGE this_
inner join TB_BTG_SWIFT_BASIC_HEADER basicheade1_ on this_.ID_BASIC_HEADER=basicheade1_.ID_BASIC_HEADER
inner join TB_BTG_SWIFT_APPLICATION_HEADER appheadera2_ on this_.ID_APPLICATION_HEADER=appheadera2_.ID_APPLICATION_HEADER
inner join TB_BTG_SWIFT_TYPED_MESSAGE typedalias3_ on this_.ID_TYPED_MESSAGE=typedalias3_.ID_TYPED_MESSAGE
inner join TB_BTG_SWIFT_COMMON_DATA accountali4_ on typedalias3_.ID_ACCOUNT_IDENTIFICATION=accountali4_.ID_COMMON
inner join TB_BTG_SWIFT_COMMON_DATA accountali4_ on typedalias3_.ID_ACCOUNT_IDENTIFICATION=accountali4_.ID_COMMON
inner join TB_BTG_SWIFT_COMMON_DATA accountali4_ on typedalias3_.ID_ACCOUNT_IDENTIFICATION=accountali4_.ID_COMMON
inner join TB_BTG_SWIFT_COMMON_DATA accountali4_ on typedalias3_.ID_ACCOUNT_IDENTIFICATION=accountali4_.ID_COMMON
此问题不是以下内容的重复:The correlation name 'MR' is specified multiple times in a FROM clause
Nhibernate对SQL进行控制。 我想了解为什么,如果我在映射或查询中犯了一个错误。