Ibatis.net Loop iterate, no foreach

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.