Castle ActiveRecord 如何条件批量更新或删除多条记录

jzywh 2008-03-25 10:44:41
Castle ActiveRecord 如何条件批量更新或删除多条记录?

例如希望实现功能 sql = "update Clothes set ClothesTypeId = null where ClothesTypeId = 1",

该如何做呢? 可以在SimpleQuery中写update语句么?
...全文
305 点赞 收藏 12
写回复
12 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jiejiep 2010-04-19
关注。。。
回复
DoNotTomcat 2008-04-07
ISessionFactoryHolder sessionHolder = ActiveRecordMediator.GetSessionFactoryHolder();
ISession session = sessionHolder.CreateSession(typeof(News));


try
{
System.Data.IDbCommand command = session.Connection.CreateCommand();
command.CommandText = "update news set IsPassed=" + IsPassed + " ,checkerList='" + adminRealName + "' WHERE id in('" + NewsIdList + "')";
command.ExecuteNonQuery();

}
catch (Exception e)
{
throw e;
}

sessionHolder.ReleaseSession(session);
回复
MyNameEPC 2008-04-01
The most efficient way is writing a sql query to do this. Castle support build-in query execution.
回复
jzywh 2008-03-26
Update 呢?
回复
nutpp 2008-03-25
批量删除
ActiveRecordMediator.DeleteAll(typeof(T), where);


ActiveRecordMediator.DeleteAll(typeof(T), "ClothesTypeId = 1");

T为对应的实体类
回复
nutpp 2008-03-25
ActiveRecordMediator.DeleteAll(typeof(T), where);
回复
发帖
分析与设计
创建于2007-09-28

1.3w+

社区成员

.NET技术 分析与设计
申请成为版主
帖子事件
创建了帖子
2008-03-25 10:44
社区公告
暂无公告