public SortingContext(IEnumerable<KeyValuePair<string, string>> filters) { var dict = filters.ToDictionary(kv => kv.Key, kv => kv.Value); if (dict.ContainsKey(Constants.SortingQueryName)) { var props = dict[Constants.SortingQueryName].Split(',').Select(s => s.Trim()); Properties = props.Select(p => new SortingProperty(p)); } else { Properties = new SortingProperty[0]; } }
public SortingContext(IEnumerable <KeyValuePair <string, string> > filters) { var dict = filters.ToDictionary(kv => kv.Key, kv => kv.Value); if (dict.ContainsKey(Constants.QueryNames.Sorting)) { var props = dict[Constants.QueryNames.Sorting].Split(',').Select(s => s.Trim()); Properties = props.Select(p => new SortingProperty(p)); } else { Properties = new SortingProperty[0]; } }
private IQueryable ApplyProperty(IQueryable queryable, SortingProperty property, bool isFirst) { try { var propertyName = property.Name == "Id" ? _resource.IdProperty : property.Name; queryable = queryable.ApplyQuery( GetQueryMethod(property.Direction, isFirst), Lambda.SelectProperty(queryable.ElementType, propertyName)) as IQueryable; return queryable; } catch (ArgumentException ex) { throw MissingProperty(property.Name, ex); } }
private IQueryable ApplyProperty(IQueryable queryable, SortingProperty property, bool isFirst) { try { var propertyName = property.Name == "Id" ? _resource.IdProperty : property.Name; queryable = queryable.ApplyQuery( GetQueryMethod(property.Direction, isFirst), Lambda.SelectProperty(queryable.ElementType, propertyName)) as IQueryable; return(queryable); } catch (ArgumentException ex) { throw MissingProperty(property.Name, ex); } }
private IEnumerable ApplyProperty(IEnumerable enumerable, SortingProperty property, bool isFirst) { try { var elementType = enumerable .GetType() .GetInterface("IEnumerable`1") .GetGenericArguments() .First(); var propertyName = property.Name == "Id" ? _resource.IdProperty : property.Name; enumerable = enumerable.ApplyQuery( GetQueryMethod(property.Direction, isFirst), Lambda.SelectProperty(elementType, propertyName)) as IEnumerable; return(enumerable); } catch (ArgumentException ex) { throw MissingProperty(property.Name, ex); } }
private IEnumerable ApplyProperty(IEnumerable enumerable, SortingProperty property, bool isFirst) { try { var elementType = enumerable .GetType() .GetInterface("IEnumerable`1") .GetGenericArguments() .First(); var propertyName = property.Name == "Id" ? _resource.IdProperty : property.Name; enumerable = enumerable.ApplyQuery( GetQueryMethod(property.Direction, isFirst), Lambda.SelectProperty(elementType, propertyName)) as IEnumerable; return enumerable; } catch (ArgumentException ex) { throw MissingProperty(property.Name, ex); } }