关于Linq to DataSet
生活随笔
收集整理的這篇文章主要介紹了
关于Linq to DataSet
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
代碼 ??private?PagedDataSource?BindMethod(PagedDataSource?pds,?string?keyword)
????????{
????????????OthersTradeBo?bo?=?null;
????????????try
????????????{
????????????????bo?=?new?OthersTradeBo();
????????????????DataSet?ds?=?responseDataSet(bo);
????????????????DataTable?dt?=?ds.Tables[0];
????????????????//空白時候,搜索全部
????????????????if?(string.IsNullOrEmpty(keyword))
????????????????{
????????????????????DataView?dv?=?ds.Tables[0].DefaultView;?
????????????????????pds.DataSource?=?dv;//視圖用于綁定到頁面
????????????????????_recordCount?=?ds.Tables[0].DefaultView.Count;
????????????????}
????????????????else
????????????????{
????????????????????var?temp?=?from?c?in?dt.AsEnumerable()?where?c.Field<String>("InformationTitle").Contains(keyword)?select?c;
????????????????????//dt.AsEnumerable().Where(c?=>?c.Field<String>("InformationTitle").Contains(keyword));??//另外的寫法,效果一樣
????????????????????pds.DataSource?=?temp.AsDataView();
????????????????????_recordCount?=?temp.Count();
????????????????}
????????????????bindPageButtons(_recordCount,?_pagesize);
????????????????return?pds;
????????????}
????????????finally?{?if?(bo?!=?null)bo.Dispose();?}
????????}
????????{
????????????OthersTradeBo?bo?=?null;
????????????try
????????????{
????????????????bo?=?new?OthersTradeBo();
????????????????DataSet?ds?=?responseDataSet(bo);
????????????????DataTable?dt?=?ds.Tables[0];
????????????????//空白時候,搜索全部
????????????????if?(string.IsNullOrEmpty(keyword))
????????????????{
????????????????????DataView?dv?=?ds.Tables[0].DefaultView;?
????????????????????pds.DataSource?=?dv;//視圖用于綁定到頁面
????????????????????_recordCount?=?ds.Tables[0].DefaultView.Count;
????????????????}
????????????????else
????????????????{
????????????????????var?temp?=?from?c?in?dt.AsEnumerable()?where?c.Field<String>("InformationTitle").Contains(keyword)?select?c;
????????????????????//dt.AsEnumerable().Where(c?=>?c.Field<String>("InformationTitle").Contains(keyword));??//另外的寫法,效果一樣
????????????????????pds.DataSource?=?temp.AsDataView();
????????????????????_recordCount?=?temp.Count();
????????????????}
????????????????bindPageButtons(_recordCount,?_pagesize);
????????????????return?pds;
????????????}
????????????finally?{?if?(bo?!=?null)bo.Dispose();?}
????????}
其中代碼片段。
轉載于:https://www.cnblogs.com/drek_blog/archive/2010/04/12/1709939.html
總結
以上是生活随笔為你收集整理的关于Linq to DataSet的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 关于DataAccess Applica
- 下一篇: Source Server + Symb