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 Listjava

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 clausessql

Element Description
<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>

api

一、prepend:前綴的意思app

二、open="(" close=")"  使用括號括起來的意思ui

三、conjunction :表示用or 填充this

四、consultation_doctor_team_member_id = #[].consultation_doctor_team_member_id#
and permission_id = #[].permission_id# 下邊是循環體spa

##表示變量,[]表示數據索引,相似於C#代碼中[i].net

用.獲取屬性索引

特此聲明,iBatis.net沒有foreach,查邊官方文檔,沒有這個api或標籤。java版本的有!ip

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'

困擾了一下午

相關文章
相關標籤/搜索