public void Create_Property_MapToInvalidProperty_Throws() { var definition = TestListDefinition.Create <Request, Item, Result2>(); var expression = new PageExpression <Request, Result2>(x => x.Page); definition.PageDefinition = expression; Factory.Invoking(x => x.Create(definition)) .Should() .ThrowExactly <PropertyNotFoundException>(); }
public void Create_Name_DefaultValueByAttribute_Succeeds() { var definition = TestListDefinition.Create <Request2, Item, Result>(); var expression = new PageExpression <Request2, Result>("Page"); definition.PageDefinition = expression; var configuration = Factory.Create(definition); configuration.RequestProperty.Name.Should().Be("Page"); configuration.ResultProperty.Name.Should().Be("Page"); configuration.DefaultValue.Should().Be(2); configuration.Name.Should().BeNull(); }
public void Create_Property_MapTo_Property_Succeeds() { var definition = TestListDefinition.Create <Request, Item, Result2>(); var expression = new PageExpression <Request, Result2>(x => x.Page); expression.MapTo(x => x.CurrentPage); definition.PageDefinition = expression; var configuration = Factory.Create(definition); configuration.RequestProperty.Name.Should().Be("Page"); configuration.ResultProperty.Name.Should().Be("CurrentPage"); configuration.DefaultValue.Should().Be(1); configuration.Name.Should().BeNull(); }
void dataPager_Click(object sender, RoutedEventArgs e) { PageExpression pager = Queryer.QueryExpression.Pager; int minRow = pager.PreRowCount / pager.PageSize -1; int subPageCount = this.dataPager.PageIndex - pager.PageIndex; if (subPageCount <= minRow && subPageCount >= 0) { // this.ItemsSource var data = this.ItemsSource.Skip(subPageCount * pager.PageSize).Take(pager.PageSize); this.ADtGrid.ItemsSource = data; } else { this.Pager.PageIndex = this.dataPager.PageIndex; Queryer.Query(); } }
public IQueryable <TEntity> FilterPage <TEntity>(IQueryable <TEntity> queryData, PageExpression pager) { int skipNum = (pager.PageIndex - 1) * pager.PageSize; int takeNum = pager.PreRowCount; int rowCount = queryData.Count(); int pageCount = rowCount / pager.PageSize; if (rowCount % pager.PageSize > 0) { pageCount++; } pager.PageCount = pageCount; if (pageCount < pager.PageIndex) { pager.PageIndex = pageCount == 0 ? 1 : pageCount; } return(queryData.ToList().AsQueryable().Skip(skipNum).Take(takeNum)); }