public QueryableSortVisitor( InputObjectType initialType, Type source) : base(initialType) { if (initialType is null) { throw new ArgumentNullException(nameof(initialType)); } Closure = new SortQueryableClosure(source, _parameterName); }
public QueryableSortVisitorContext( InputParser inputParser, InputObjectType initialType, Type source, bool inMemory) : base(initialType) { if (source is null) { throw new ArgumentNullException(nameof(source)); } Closure = new SortQueryableClosure(source, _parameterName); InputParser = inputParser ?? throw new ArgumentNullException(nameof(inputParser)); InMemory = inMemory; }
public void AddSortOperation_DescOnIOrderedQueryable_ShouldAddThenByDescending() { // arrange IOrderedQueryable <Foo> source = new Foo[0].AsQueryable().OrderBy(f => f.Bar); var closure = new SortQueryableClosure(typeof(Foo), "p"); closure.EnqueueProperty(typeof(Foo).GetProperty(nameof(Foo.Bar))); var operation = closure.CreateSortOperation(SortOperationKind.Desc); // act IOrderedQueryable <Foo> sorted = source.AddInitialSortOperation( operation ); // assert Assert.Equal(source.ThenByDescending(s => s.Bar), sorted); }
public void CompileInitialSortOperation_AscOnIQueryable_ShouldAddOrderBy() { // arrange IQueryable <Foo> source = new Foo[0].AsQueryable(); var closure = new SortQueryableClosure(typeof(Foo), "p"); closure.EnqueueProperty(typeof(Foo).GetProperty(nameof(Foo.Bar))); SortOperationInvocation operation = closure.CreateSortOperation(SortOperationKind.Asc); // act Expression sortExpression = source.Expression.CompileInitialSortOperation( operation ); IQueryable <Foo> sorted = source.Provider.CreateQuery <Foo>(sortExpression); // assert Assert.Equal(source.OrderBy(s => s.Bar), sorted); }