`
t641339564
  • 浏览: 26335 次
  • 性别: Icon_minigender_1
  • 来自: 贵阳
社区版块
存档分类
最新评论

IBatisNet 模糊查询

    博客分类:
  • C#
阅读更多

<select id="Client_Search" resultMap="Client_AllColumns_search"  parameterClass="Client">
   SELECT
   Client.*,
   <!--要查询的字段,如果一级行业为空则不查询-->
     <isNotNull prepend="" property="FirstIndustry">
    Industry.[Industry_Name],
    Industry.[Industry_Id],
   </isNotNull> 
 
   Users.[UserName],
   Users.[UserRealName],
   Users.[UserId]

   FROM Client,Users
  <!--判断是否要连接表-->
  <isNotNull prepend="," property="FirstIndustry">Industry</isNotNull>
   
   
   <isEmpty prepend="" property="BethroughItemArray" >
   <isNotEmpty prepend="," property="ItemArray">BusinessModel,Business_Note,Project</isNotEmpty>
   </isEmpty>

   <isEmpty prepend="" property="ItemArray" >
    <isNotEmpty prepend="," property="BethroughItemArray">BusinessModel,Business_Note,Project</isNotEmpty>
   </isEmpty>

   <isNotEmpty prepend="," property="BethroughItemArray" >
    <isNotEmpty prepend="" property="ItemArray">BusinessModel,Business_Note,Project</isNotEmpty>
   </isNotEmpty>
   where  Users.[UserId]=Client.[Import_User_Id] and Client.[Client_Sign]=0


   <!--一级行业-->
   <isNotNull prepend="AND" property="FirstIndustry">
    Client.First_Industry=#FirstIndustry#
    and Client.First_Industry=Industry.Industry_Id
   </isNotNull>
   <!--二级行业-->
   <isNotNull prepend="AND" property="SecondIndustry">
    Client.Second_Industry=#SecondIndustry# 
   </isNotNull>
     <!--客户名称 模糊查询-->
   <isNotEmpty prepend="AND" property="ClientName">Client.Client_Name like '%$ClientName$%'</isNotEmpty>
   <!--查询代码-->
   <isNotEmpty prepend="AND" property="ClientCode">Client.Client_Code like '%$ClientCode$%'</isNotEmpty>
     <!--其他录入人-->
   <isNotEmpty prepend="AND" property="IsUser">Client.Import_User_Id!=#ImportUserId#</isNotEmpty>
   <!--所在省-->
   <isNotNull prepend="AND" property="ProvinceID">Client.provinceID=#ProvinceID#</isNotNull>
   <!--客户编号-->
   <isNotEmpty prepend="AND" property="ClientId">Client.Client_Id  like '%$ClientId$%'</isNotEmpty>
   <!--做过的项目 在类里传一个ArrayList-->   

<isNotEmpty prepend="AND" property="BethroughItemArray">
  
    <iterate  prepend="" property="BethroughItemArray" open="("  close=")"  conjunction="and" >
     Client.Id in (select BusinessModel.Client_Auto_Id from BusinessModel,Business_Note where Business_Note.Business_Id=BusinessModel.Business_Id
     and Business_Note.Project_Id=#BethroughItemArray[].Value#)
    </iterate>    
   </isNotEmpty>
    </select>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics