首页 > 代码库 > Ibatis批量处理
Ibatis批量处理
1.插入
<insert id="insTable" resultClass="int"> INSERT INTO [dbo].[table] ([Id] ,[FId],[IsDel],[CreateTime] ) VALUES <iterate conjunction="," open="" close=""> (#[].Id# ,#[].FId# ,0 ,GETDATE() ) </iterate> </insert>
2.读取
<select id="queryTable" resultMap="Table" parameterClass="List"> select Id, FId, CreateTime from Table (nolock) where IsDel=1 and [Id] in <iterate open="(" close=")" conjunction=","> #[]# </iterate> </select>
3.修改
<update id="updateTable" parameterClass="list"> begin <iterate conjunction=""> update TABLE set Fid=#[].FId# where id = #[].Id#; </iterate> end; </update>
var tables = new List<Table>() { {new Table() {Id = 1, FId = "100"}}, {new Table() {Id = 2, FId = "102"}}, }; this.mapper.Update("updateTable", tables);
4.删除
<delete id="delTable" parameterClass="List"> delete from TABLE where id in <iterate conjunction="," open="(" close=")"> #[]# </iterate> </delete>
var ids=new List<int>(){2,3,4}; this.mapper.Delete("delTable", ids);
Ibatis批量处理
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。