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);
时间: 2024-10-10 02:19:26