当前位置: 首页>>代码示例>>C#>>正文


C# IQueryable.ToDataTable方法代码示例

本文整理汇总了C#中IQueryable.ToDataTable方法的典型用法代码示例。如果您正苦于以下问题:C# IQueryable.ToDataTable方法的具体用法?C# IQueryable.ToDataTable怎么用?C# IQueryable.ToDataTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IQueryable的用法示例。


在下文中一共展示了IQueryable.ToDataTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FilterDataSource

 private JsonResult FilterDataSource(object dataSource, NameValueCollection queryString, out IQueryable iqueryable)
 {
     iqueryable = dataSource as IQueryable;
     Guard.IsNotNull(iqueryable, "DataSource", "should implement the IQueryable interface.");
     int pageIndex = this.GetPageIndex(queryString["page"]);
     int count = Convert.ToInt32(queryString["rows"]);
     string primaryKeyField = queryString["sidx"];
     string sortDirection = queryString["sord"];
     string text1 = queryString["parentRowID"];
     string str3 = queryString["_search"];
     string str4 = queryString["filters"];
     string str5 = queryString["searchField"];
     string searchString = queryString["searchString"];
     string searchOper = queryString["searchOper"];
     this.PagerSettings.CurrentPage = pageIndex;
     this.PagerSettings.PageSize = count;
     if (!string.IsNullOrEmpty(str3) && (str3 != "false"))
     {
         try
         {
             if (string.IsNullOrEmpty(str4) && !string.IsNullOrEmpty(str5))
             {
                 iqueryable = iqueryable.Where(Trirand.Web.Mvc.Util.GetWhereClause(this, str5, searchString, searchOper), new object[0]);
             }
             else if (!string.IsNullOrEmpty(str4))
             {
                 iqueryable = iqueryable.Where(Trirand.Web.Mvc.Util.GetWhereClause(this, str4), new object[0]);
             }
             else if (this.ToolBarSettings.ShowSearchToolBar || (str3 == "true"))
             {
                 iqueryable = iqueryable.Where(Trirand.Web.Mvc.Util.GetWhereClause(this, queryString), new object[0]);
             }
         }
         catch (DataTypeNotSetException exception)
         {
             throw exception;
         }
         catch (Exception)
         {
             return new JsonResult { Data = new object(), JsonRequestBehavior = JsonRequestBehavior.AllowGet };
         }
     }
     int totalRowCount = iqueryable.Count();
     int totalPagesCount = (int) Math.Ceiling((double) (((float) totalRowCount) / ((float) count)));
     if (string.IsNullOrEmpty(primaryKeyField) && this.SortSettings.AutoSortByPrimaryKey)
     {
         if (this.Columns.Count == 0)
         {
             throw new Exception("JQGrid must have at least one column defined.");
         }
         primaryKeyField = Trirand.Web.Mvc.Util.GetPrimaryKeyField(this);
         sortDirection = "asc";
     }
     if (!string.IsNullOrEmpty(primaryKeyField))
     {
         iqueryable = iqueryable.OrderBy(this.GetSortExpression(primaryKeyField, sortDirection), new object[0]);
     }
     iqueryable = iqueryable.Skip(((pageIndex - 1) * count)).Take(count);
     DataTable dt = iqueryable.ToDataTable(this);
     this.OnDataResolved(new JQGridDataResolvedEventArgs(this, iqueryable, this.DataSource as IQueryable));
     if (this.TreeGridSettings.Enabled)
     {
         JsonTreeResponse response = new JsonTreeResponse(pageIndex, totalPagesCount, totalRowCount, count, dt.Rows.Count, Trirand.Web.Mvc.Util.GetFooterInfo(this));
         return Trirand.Web.Mvc.Util.ConvertToTreeJson(response, this, dt);
     }
     JsonResponse response2 = new JsonResponse(pageIndex, totalPagesCount, totalRowCount, count, dt.Rows.Count, Trirand.Web.Mvc.Util.GetFooterInfo(this));
     return Trirand.Web.Mvc.Util.ConvertToJson(response2, this, dt);
 }
开发者ID:gerasyana,项目名称:Academy,代码行数:68,代码来源:JQGrid.cs


注:本文中的IQueryable.ToDataTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。