實體類
publicint ids
public
string code
public
string name
public
decimal oil
public
decimal price
封裝類注意引用using system.data.sqlclient;
sqlconnection conn = null; sqlcommand cmd = null
;
public
cardata()
//查詢全部
public listselectall()
}conn.close();
return
clist;
}//分頁查詢
public listselectall(int count, int
number)
}conn.close();
return
clist;
}//查詢資料條數
public
intselectcount()
//條件查詢
public listselectall(string
tsql, hashtable hs)
conn.open();
sqldatareader dr =cmd.executereader();
if(dr.hasrows)
}conn.close();
return
clist;
}
前端
名稱:"textbox1
" runat="
server
">油耗:
"dropdownlist1
" runat="
server
">
"小於" value="
<
">
"小於等於
" value="
<=
">
"等於" value="
=">
"大於等於
" value="
>=
">
"大於" value="
>
">
"textbox2
" runat="
server
">**:
"dropdownlist2
" runat="
server
">
"任意金額
" value="
null
">
"小於30萬
" value="
price < 30
">
"大於30萬小於40萬
" value="
price > 30 and price < 40
">
"大於40萬小於50萬
" value="
price > 40 and price < 50
">
"大於50萬
" value="
price > 40
">
"button1
" runat="
server
" text="
查詢" />
"width: 100%; background-color: #0094ff; text-align: center;
">
ids編號名稱
油耗**
"repeater1
" runat="
server
">
"background-color: #fff;
">
<%#eval("
ids") %>
<%#eval("
code
") %>
<%#eval("
name
") %>
<%#eval("
oil") %>
<%#eval("
price
") %>
後台
if (!ispostback)//查詢按鈕
button1.click +=button1_click;
}void button1_click(object
sender, eventargs e)
if (textbox2.text.trim().length > 0
)
else
hs.add("@b
", "
textbox2.text.trim()");
count++;
}if (dropdownlist2.selectedvalue != "
null")
else
count++;
}//資料繫結
repeater1.datasource = new
cardata().selectall(tsql,hs);
repeater1.databind();
}
SpringbootDataJpa條件查詢和分頁
public queryresponseresult findallpage int page,int size,requestdata requestdata 自定義條件查詢 定義條件匹配器 examplematcher examplematcher examplematcher.matching...
Spring data jpa多表查多條件查詢
現有如下場景,需要根據a表的check code欄位和b表的store code check result欄位組合查詢,a表與b表的關聯關係為一對多。為了簡化查詢引數,我們對查詢引數進行了封裝,抽出了公共的querycondition public class querycondition publ...
八 Spring Data JPA多條件分頁查詢
多條件查詢 public page pagequery label label,integer page,integer size 標籤狀態 if stringutils.isnotblank label.getstate predicate parr newpredicate list.size ...