本文整理汇总了C#中SearchResult.SetPage方法的典型用法代码示例。如果您正苦于以下问题:C# SearchResult.SetPage方法的具体用法?C# SearchResult.SetPage怎么用?C# SearchResult.SetPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchResult
的用法示例。
在下文中一共展示了SearchResult.SetPage方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SearchNews
public SearchResult<tblNew> SearchNews(int pageSize, int page, String sortColunm, String sortOption)
{
SearchResult<tblNew> searchResult = new SearchResult<tblNew>();
var query1 = _dataContext.tblNews.Where("Title!=null");
var query = query1;
if (sortColunm == "Title")
{
if (sortOption == ABDHFramework.Data.SortOption.Desc.ToString())
{
query = _dataContext.tblNews
.Where("Title!=null")
.OrderByDescending(o => o.Title)
.Take(pageSize * page)
.Skip((page - 1) * pageSize)
;
}
else
{
query = _dataContext.tblNews
.Where("Title!=null")
.OrderBy(o => o.Title)
.Take(pageSize * page)
.Skip((page - 1) * pageSize)
;
}
}
else
{
query = _dataContext.tblNews
.Where("Title!=null")
.Take(pageSize * page)
.Skip((page - 1) * pageSize);
}
if (query != null && query1 != null && query.ToList().Count > 0)
{
searchResult.Items = query.ToList();
searchResult.Query = query;
searchResult.SetMaxResults(pageSize);
searchResult.SetPage(page);
searchResult.TotalRows = query1.Count();
}
return searchResult;
}
示例2: GetAllProduct
public SearchResult<tblProduct> GetAllProduct(int pageSize, int page,byte language, String criteria, String sortColunm, String sortOption)
{
SearchResult<tblProduct> searchResult = new SearchResult<tblProduct>();
var query1 = _dataContext.tblProducts.Where(item => item.ProductName.Contains(criteria) && item.Language.HasValue && item.Language.Value.Equals(language));
var query = query1;
if (sortOption == "Desc")
{
query = _dataContext.tblProducts.Where(item => item.ProductName.Contains(criteria) && item.Language.HasValue && item.Language.Value.Equals(language)).Take(pageSize * page).Skip((page - 1) * pageSize).OrderBy(item=>item.ProductName);
}
else
{
query = _dataContext.tblProducts.Where(item => item.ProductName.Contains(criteria) && item.Language.HasValue && item.Language.Value.Equals(language)).Take(pageSize * page).Skip((page - 1) * pageSize).OrderByDescending(item=>item.ProductName);
}
if (query != null && query1 != null && query.ToList().Count > 0)
{
searchResult.Items = query.ToList();
searchResult.Query = query;
searchResult.SetMaxResults(pageSize);
searchResult.SetPage(page);
searchResult.TotalRows = query1.Count();
}
return searchResult;
}
示例3: GetAllProductByCategory
public SearchResult<tblProduct> GetAllProductByCategory(int pageSize, int page, Guid? categoryID)
{
SearchResult<tblProduct> searchResult = new SearchResult<tblProduct>();
var query1 = _dataContext.tblProducts.Where("CategoryID.HasValue and CategoryID.Value.ToString()[email protected]", ((Guid)categoryID).ToString());
var query = _dataContext.tblProducts.Where("CategoryID.HasValue and CategoryID.Value.ToString()[email protected]", ((Guid)categoryID).ToString()).Take(pageSize * page).Skip((page - 1) * pageSize);
if (query != null && query1 != null && query.ToList().Count > 0)
{
searchResult.Items = query.ToList();
searchResult.Query = query;
searchResult.SetMaxResults(pageSize);
searchResult.SetPage(page);
searchResult.TotalRows = query1.Count();
}
return searchResult;
}
示例4: GetAllCategory
public SearchResult<tblCategory> GetAllCategory(int pageSize, int page, bool isEN, string criteria, String sortColunm, String sortOption)
{
isEN = false;
SearchResult<tblCategory> searchResult = new SearchResult<tblCategory>();
if (!isEN)
{
var query1 = _dataContext.tblCategories.Where("CategoryName!=null");
var query = query1;
if (sortColunm == "CategoryName")
{
if (sortOption == ABDHFramework.Data.SortOption.Desc.ToString())
{
query = _dataContext.tblCategories
.Where(op => op.CategoryName.Contains(criteria))
.OrderByDescending(o => o.CategoryName)
.Take(pageSize * page)
.Skip((page - 1) * pageSize)
;
}
else
{
query = _dataContext.tblCategories
.Where(op => op.CategoryName.Contains(criteria))
.OrderBy(o => o.CategoryName)
.Take(pageSize * page)
.Skip((page - 1) * pageSize)
;
}
}
else
{
query = _dataContext.tblCategories
.Where(op => op.CategoryName.Contains(criteria))
.OrderByDescending(o => o.CategoryName)
.Take(pageSize * page)
.Skip((page - 1) * pageSize)
;
}
if (query != null && query1 != null && query.ToList().Count > 0)
{
searchResult.Items = query.ToList();
searchResult.Query = query;
searchResult.SetMaxResults(pageSize);
searchResult.SetPage(page);
searchResult.TotalRows = query1.Count();
}
}
else
{
var query1 = _dataContext.tblCategories.Where("CategoryName!=null");
var query = _dataContext.tblCategories.Where("CategoryName!=null").Take(pageSize * page).Skip((page - 1) * pageSize);
if (query != null && query1 != null && query.ToList().Count > 0)
{
searchResult.Items = query.ToList();
searchResult.Query = query;
searchResult.SetMaxResults(pageSize);
searchResult.SetPage(page);
searchResult.TotalRows = query1.Count();
}
}
return searchResult;
}
示例5: GetAllProduct
public SearchResult<tblProduct> GetAllProduct(int pageSize, int page,bool isEN)
{
SearchResult<tblProduct> searchResult = new SearchResult<tblProduct>();
if (isEN)
{
var query1 = _dataContext.tblProducts.Where("ProductNameEN!=null");
var query = _dataContext.tblProducts.Where("ProductNameEN!=null").Take(pageSize * page).Skip((page - 1) * pageSize);
if (query != null && query1 != null && query.ToList().Count > 0)
{
searchResult.Items = query.ToList();
searchResult.Query = query;
searchResult.SetMaxResults(pageSize);
searchResult.SetPage(page);
searchResult.TotalRows = query1.Count();
}
}
else
{
var query1 = _dataContext.tblProducts.Where("ProductNameVN!=null");
var query = _dataContext.tblProducts.Where("ProductNameVN!=null").Take(pageSize * page).Skip((page - 1) * pageSize);
if (query != null && query1 != null && query.ToList().Count > 0)
{
searchResult.Items = query.ToList();
searchResult.Query = query;
searchResult.SetMaxResults(pageSize);
searchResult.SetPage(page);
searchResult.TotalRows = query1.Count();
}
}
return searchResult;
}
示例6: GetAllNews
public SearchResult<tblNew> GetAllNews(int pageSize, int page,byte type,bool isEN)
{
SearchResult<tblNew> searchResult = new SearchResult<tblNew>();
if (!isEN)
{
var query1 = _dataContext.tblNews.Where("[email protected] and SubjectVN!=null", type);
var query = _dataContext.tblNews.Where("[email protected] and SubjectVN!=null", type).Take(pageSize * page).Skip((page - 1) * pageSize);
if (query != null && query1 != null && query.ToList().Count > 0)
{
searchResult.Items = query.ToList();
searchResult.Query = query;
searchResult.SetMaxResults(pageSize);
searchResult.SetPage(page);
searchResult.TotalRows = query1.Count();
}
}
else
{
var query1 = _dataContext.tblNews.Where("[email protected] and SubjectEN!=null", type);
var query = _dataContext.tblNews.Where("[email protected] and SubjectEN!=null", type).Take(pageSize * page).Skip((page - 1) * pageSize);
if (query != null && query1 != null && query.ToList().Count > 0)
{
searchResult.Items = query.ToList();
searchResult.Query = query;
searchResult.SetMaxResults(pageSize);
searchResult.SetPage(page);
searchResult.TotalRows = query1.Count();
}
}
return searchResult;
}