0

我有 2 个具有以下设置的课程:

[ActiveRecord("ReceivedMessage")]
class ARReceivedMessage : ARBase<ARReceivedMessage>

和:

[ActiveRecord("ReceivedMessageReply")]
class ARReceivedMessageReply : ARBase<ARReceivedMessageReply>

[BelongsTo(Type = typeof(ARReceivedMessage), Column = "ReceivedMessageID")]
public ARReceivedMessage Message { get; set; }

在尝试清理数据库时,我首先要删除所有 ReceivedMessageReply 对象,然后再删除 ReceivedMessage 本身。在代码中,这使我想到了以下内容:

获取我要删除的所有收到的消息:

ARReceivedMessage[] messagesToDelete = ARReceivedMessage.GetAll(messageCriterion);

获取删除所有 ReceivedMessageReplys 的标准并删除它们:

ICriterion relatedCriterion = Restrictions.In("ReceivedMessageID", messagesToDelete);
ARReceivedMessageReply.DeleteAll(relatedCriterion);

不知何故,activerecord告诉我以下内容:无法解析属性:ReceivedMessageID of:ARReceivedMessageReply

知道我在哪里犯了错误吗?

提前致谢

4

1 回答 1

0

不知何故,我不得不使用以下内容:

ICriterion relatedCriterion = Restrictions.In("Message", messagesToDelete);

所以不是activerecord设置的columnname/propertyname,而是属性名本身。这是出乎意料的……

于 2013-03-11T10:16:37.140 回答