我是靠谱客的博主 谨慎小兔子,最近开发中收集的这篇文章主要介绍iBatis.net 循环iterate,没有foreach,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

3.9.4. Iterate Element

This tag will iterate over a collection and repeat the body content for each item in a List

3.9.4.1. Iterate Attributes:

prepend – the overridable SQL part that will be prepended to the statement (optional)
property – a property of type IList that is to be iterated over (required)
open – the string with which to open the entire block of iterations, useful for brackets (optional)
close – the string with which to close the entire block of iterations, useful for brackets (optional)
conjunction – the string to be applied in between each iteration, useful for AND and OR (optional)

Table 3.10. Creating a list of conditional clauses

ElementDescription
<iterate>Iterates over a property that is of type IList Example Usage:
<iterate prepend="AND" property="UserNameList"
open="(" close=")" conjunction="OR">
username=#UserNameList[]#
</iterate>
Note: It is very important to include the square brackets[] at the end of the List property name when using the Iterate element. These brackets distinguish this object as an List to keep the parser from simply outputting the List as a string.

     
 
 
上边是官方的文档,看了一下,
举个例子

<iterate prepend=" "
open="(" close=")" conjunction=" OR ">
consultation_doctor_team_member_id = #[].consultation_doctor_team_member_id#
and permission_id = #[].permission_id#
</iterate>

1、prepend:前缀的意思

2、open="(" close=")"  使用括号括起来的意思

3、conjunction :表示用or 填充

4、consultation_doctor_team_member_id = #[].consultation_doctor_team_member_id#
and permission_id = #[].permission_id# 下边是循环体

##表示变量,[]表示数据索引,类似于C#代码中[i]

用.获取属性

特此声明,iBatis.net没有foreach,查边官方文档,没有这个api或标签。java版本的有!

sql 监视语句:

EXEC sp_executesql N'SELECT * FROM dbo.t_c_team_member_permission where ( consultation_doctor_team_member_id = @param0 and permission_id = @param1 OR consultation_doctor_team_member_id = @param2 and permission_id = @param3 )',
N'@param0 nvarchar(16),@param1 nvarchar(1),@param2 nvarchar(16),@param3 nvarchar(1)',
@param0 = N'CONDTM0000000033', @param1 = N'1',
@param2 = N'CONDTM0000000032', @param3 = N'1'

困扰了一下午

 

 

转载于:https://www.cnblogs.com/zuolijun/p/5440155.html

最后

以上就是谨慎小兔子为你收集整理的iBatis.net 循环iterate,没有foreach的全部内容,希望文章能够帮你解决iBatis.net 循环iterate,没有foreach所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部