3.9.4. Iterate Element
This tag would 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'll be prepended to the statement (optional) |
Property–a property of type IList-is-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 is applied in between each iteration, useful for and and OR (optional) |
Table 3.10. Creating a list of conditional clauses
Element |
Description |
<iterate> |
Iterates over a property the 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 El Ement. These brackets distinguish this object as a list to keep the parser from simply outputting the list as a string.
|
The top is an official document, look at it, for instance.
<iterate prepend= ""
Open= "(" close= ")" conjunction= "OR" >
consultation_doctor_team_member_id = #[].consultation_doctor_team_member_id#
and permission_id = #[].permission_id#
</iterate>
1, prepend: The meaning of the prefix
2, open= "(" close= ")" with parentheses in the meaning
3. Conjunction: means filled with or
4, consultation_doctor_team_member_id = #[].consultation_doctor_team_member_id#
and permission_id = #[].permission_id# Below is the loop body
# #表示变量, [] represents the data index, similar to C # code [i]
Use the. Get Properties
It is hereby stated that Ibatis.net does not have a foreach, official document on the edge, without this API or tag. Java version of There!
SQL monitoring statements:
EXEC sp_executesql N ' SELECT * from dbo.t_c_team_member_permission where (consultation_doctor_team_member_id = @param0 an D permission_id = @param1 OR consultation_doctor_team_member_id = @param2 and permission_id = @param3) ',
N ' @param0 nvarchar (+), @param1 nvarchar (1), @param2 nvarchar (+), @param3 nvarchar (1) ',
@param0 = N ' CONDTM0000000033 ', @param1 = n ' 1 ',
@param2 = N ' CONDTM0000000032 ', @param3 = n ' 1 '
Troubled the whole afternoon
Ibatis.net Loop iterate, no foreach