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'

困扰了一下午

 

 

posted @ 2016-04-27 19:49  左立军  阅读(2494)  评论(0编辑  收藏  举报