Castle ActiveRecord DeleteAll on belongssto restraint

时间:2013-03-11 09:54:41

标签: c# nhibernate activerecord castle-activerecord castle

我有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:ARReceivedMessageReply

知道我犯了什么错误吗?

提前致谢

1 个答案:

答案 0 :(得分:0)

不知怎的,我不得不使用以下内容:

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

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