public void Parse_WithVirtualRelationEndPoint() { var orderClassDefinition = MappingConfiguration.Current.GetTypeDefinition(typeof(Order)); var parser = new SortExpressionParser(orderClassDefinition); var sortExpression = "OrderTicket"; parser.Parse(sortExpression); }
public void Test2() { var member = new Stack <string>(); var method = new Stack <int>(); var repo = new SortExpressionParser(); repo.Parsing <Fee>(i => i.OrderBy(j => new { j.Name, j.Age, j.Email }), member, method); Assert.Equal(method.Count, (int)3); }
public void Test1() { var member = new Stack <string>(); var method = new Stack <int>(); var repo = new SortExpressionParser(); repo.Parsing <Fee>(i => i.OrderBy(j => j.Name).ThenBy(j => j.Age).ThenByDescending(j => j.Email), member, method); Assert.Equal(method.Count, (int)3); }
public override void SetUp() { base.SetUp(); _orderItemClassDefinition = MappingConfiguration.Current.GetTypeDefinition(typeof(OrderItem)); _productPropertyDefinition = _orderItemClassDefinition.GetMandatoryPropertyDefinition(typeof(OrderItem).FullName + ".Product"); _positionPropertyDefinition = _orderItemClassDefinition.GetMandatoryPropertyDefinition(typeof(OrderItem).FullName + ".Position"); _orderPropertyDefinition = _orderItemClassDefinition.GetMandatoryPropertyDefinition(typeof(OrderItem).FullName + ".Order"); _parser = new SortExpressionParser(_orderItemClassDefinition); }
public IQueryable <T> Parse(IQueryable <T> source, NameValueCollection queryParams) { if (queryParams.Count == 0) { return(source); } source = FilterExpressionParser.Parse(source, queryParams[FilterParameter]); source = SortExpressionParser.Parse(source, queryParams[OrderByParameter]); source = SelectExpressionParser.Parse(source, queryParams[SelectParameter]); return(source); }
public void Parse_WithDerivedProperty() { var partnerClassDefinition = MappingConfiguration.Current.GetTypeDefinition(typeof(Partner)); var parser = new SortExpressionParser(partnerClassDefinition); var sortExpression = "Remotion.Data.DomainObjects.UnitTests.TestDomain.Distributor.NumberOfShops"; var result = parser.Parse(sortExpression); var distributorClassDefinition = MappingConfiguration.Current.GetTypeDefinition(typeof(Distributor)); var numberOfShopsPropertyDefinition = distributorClassDefinition.GetMandatoryPropertyDefinition(sortExpression); var expected = new[] { SortExpressionDefinitionObjectMother.CreateSortedPropertyAscending(numberOfShopsPropertyDefinition) }; Assert.That(result.SortedProperties, Is.EqualTo(expected)); }
private Expression ParseSort(Expression expression) { var sortExpressionParser = new SortExpressionParser(); Logger.Log("Identifying sort order", Indentation.Two); var orderExpression = sortExpressionParser.Visit(expression); if (sortExpressionParser.SortProperty != null) { Logger.Log($"Sorting by {sortExpressionParser.SortProperty} {sortExpressionParser.SortDirection}", Indentation.Three); SortProperty = GetProperty(sortExpressionParser.SortProperty); SortDirection = sortExpressionParser.SortDirection; } return(orderExpression); }
private SortExpressionDefinition ParseSortExpression(string sortExpressionText) { if (sortExpressionText == null) { return(null); } try { var parser = new SortExpressionParser(this.GetOppositeEndPointDefinition().ClassDefinition); return(parser.Parse(sortExpressionText)); } catch (MappingException ex) { var result = MappingValidationResult.CreateInvalidResultForProperty(PropertyInfo, ex.Message); throw new MappingException(result.Message, ex); } }