zoukankan      html  css  js  c++  java
  • 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'

    困扰了一下午

  • 相关阅读:
    深入浅出讲解 ElasticSearch的安装与使用【建议收藏】
    win10 elasticsearch安装IK中文分词器
    elasticsearch 使用过程中经常遇到的问题
    在给elasticsearch安装head插件时,npm install 版本不匹配
    elasticsearch.bat闪退的解决方案
    图文详解| Node.js安装及环境配置之Windows篇
    面试必备:秒杀场景九个细节
    vagrant 安装中遇到的问题
    2021 年上海市成人高校考试招生工作规定
    成考专科数学模拟试题一及答案
  • 原文地址:https://www.cnblogs.com/zuolijun/p/5440155.html
Copyright © 2011-2022 走看看