本文整理汇总了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);
}