自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

iBATIS模糊查詢的實(shí)現(xiàn)實(shí)例淺析

開(kāi)發(fā) 后端
iBATIS模糊查詢的實(shí)現(xiàn)實(shí)例向你介紹了iBATIS模糊查詢是如何實(shí)現(xiàn)的,以及具體的源碼實(shí)現(xiàn)。

iBATIS模糊查詢的實(shí)現(xiàn)是如何的呢?讓我們先看看例子,仿照J(rèn)ava的Spring+Ibatis+Struct用Castle+IBatisNet+Asp.net的開(kāi)發(fā)框架的DAO的基類:BaseSqlMapDao內(nèi)定義了一個(gè)內(nèi)部類來(lái)輔助模糊查詢。內(nèi)部類代碼如下:

  1. protected internal  class KeyWordSearch   
  2.   {  
  3.    private IList keywordList = new ArrayList();  
  4.  
  5.    public KeyWordSearch(String keywords)   
  6.    {  
  7.     StringTokenizer splitter = new StringTokenizer(keywords, " "false);  
  8.     string token = null;  
  9.  
  10.     IEnumerator enumerator = splitter.GetEnumerator();  
  11.  
  12.     while (enumerator.MoveNext())   
  13.     {  
  14.      token = (string)enumerator.Current;  
  15.      keywordList.Add("%" + token + "%");  
  16.     }  
  17.    }  
  18.  
  19.    public IList KeywordList   
  20.    {  
  21.     get  
  22.     {  
  23.      return keywordList;  
  24.     }  
  25.    }  
  26.   } 

在需要使用iBATIS模糊查詢的數(shù)據(jù)訪問(wèn)類的方法中使用方法如下:

例如數(shù)據(jù)訪問(wèn)類PersonInfoDao繼承自BaseSqlMapDao,方法

  1. /// <summary>  
  2.   /// 檢索求職者信息,根據(jù)關(guān)鍵字檢索  
  3.   /// </summary>  
  4.   public IList SearchPersonInfoList(string keywords)  
  5.   {  
  6.    object parameterObject = new KeyWordSearch(keywords);  
  7.    return this.ExecuteQueryForList("SearchPersonList", parameterObject);  
  8.   }  
  9.  
  10. <select id="SearchPersonList" resultMap="PersonResult">  
  11.    select UserId,UserName,Sex,Birthday,Mobile,HomeTel,EMail,LivingArea,  
  12.             RegisteredLocus,GraduateSchool,MajorSpecialty,JobExperience,MonthlyPay,  
  13.             Special,Resume,city.code,city.name,person.NationId,Nation.NationName,  
  14.             person.JobId,job.jobName,person.degreeId,degree.DegreeName  
  15.             from Career_PersonInfo person ,Career_Nation nation,Career_Job job,Career_City city,Career_Degree degree  
  16.             where person.CityCode = city.code and person.NationId = nation.NationId and person.jobid = job.jobId  
  17.             and person.degreeId = degree.degreeId  
  18.             <dynamic prepend="and">   
  19.     <iterate property="KeywordList" open="" close="" conjunction="OR">  
  20.      lower(job.jobName) like #KeywordList[]#   
  21.     </iterate>  
  22.    </dynamic>  
  23.   </select> 

iBATIS模糊查詢的情況就向你介紹到這里,希望通過(guò)例子能夠使你對(duì)iBATIS模糊查詢的是實(shí)現(xiàn)有所幫助。

【編輯推薦】

  1. iBATIS映射文件基礎(chǔ)淺談
  2. iBATIS ParameterMap配置實(shí)例淺析
  3. iBATIS ResultMap基礎(chǔ)淺析
  4. iBATIS CacheModel使用淺析
  5. iBATIS分頁(yè)實(shí)例中ObjectDataSource的應(yīng)用淺析
責(zé)任編輯:仲衡 來(lái)源: cnblogs
相關(guān)推薦

2009-07-22 13:04:41

iBATIS動(dòng)態(tài)查詢

2009-07-22 09:44:05

iBATIS Para

2009-08-27 18:09:49

C#接口的實(shí)現(xiàn)

2009-09-04 17:20:23

C# DES加密解密

2009-08-14 09:50:46

C#復(fù)制構(gòu)造函數(shù)

2009-07-22 11:11:39

iBATIS分頁(yè)實(shí)例ObjectDataS

2009-07-24 16:59:57

iBatis模糊查詢

2009-07-15 13:11:25

ibatis動(dòng)態(tài)查詢

2009-07-20 10:06:07

iBATIS.net查詢方式

2009-07-20 17:01:11

Struts2.0+i

2009-07-17 17:45:56

iBATIS Spri

2009-07-17 10:20:24

iBATIS實(shí)例

2009-08-31 12:31:45

C#創(chuàng)建文件夾

2009-07-21 11:12:00

iBATIS配置

2009-09-14 17:10:57

LINQ模糊查詢

2009-07-17 10:59:59

iBATIS接口

2009-09-14 18:19:49

LINQ模糊查詢

2009-07-17 10:32:45

iBATIS MapB

2009-07-22 10:03:11

iBATIS Resu

2009-07-16 09:14:26

iBATIS DAO
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)