private static SearchSCIMRepresentationsResponse EvaluateOrderByMetadata( SCIMDbContext dbContext, SCIMAttributeExpression attrExpression, IQueryable <SCIMRepresentation> representations, SearchSCIMRepresentationOrders order, int startIndex, int count, IEnumerable <SCIMAttributeExpression> includedAttributes, IEnumerable <SCIMAttributeExpression> excludedAttributes) { int total = representations.Count(); var fullPath = attrExpression.GetFullPath(); if (!ParserConstants.MappingStandardAttributePathToProperty.ContainsKey(fullPath)) { return(null); } var representationParameter = Expression.Parameter(typeof(SCIMRepresentation), "rp"); var propertyName = ParserConstants.MappingStandardAttributePathToProperty[fullPath]; var property = Expression.Property(representationParameter, ParserConstants.MappingStandardAttributePathToProperty[fullPath]); var propertyType = typeof(SCIMRepresentation).GetProperty(propertyName).PropertyType; var orderBy = GetOrderByType(order, propertyType); var innerLambda = Expression.Lambda(property, new ParameterExpression[] { representationParameter }); var orderExpr = Expression.Call(orderBy, Expression.Constant(representations), innerLambda); var finalSelectArg = Expression.Parameter(typeof(IQueryable <SCIMRepresentation>), "f"); var finalOrderRequestBody = Expression.Lambda(orderExpr, new ParameterExpression[] { finalSelectArg }); var result = (IQueryable <SCIMRepresentation>)finalOrderRequestBody.Compile().DynamicInvoke(representations); var content = result.Skip(startIndex <= 1 ? 0 : startIndex - 1).Take(count); return(BuildResult(content, dbContext, includedAttributes, excludedAttributes, total)); }
private static async Task <SearchSCIMRepresentationsResponse> EvaluateOrderByMetadata( SCIMAttributeExpression attrExpression, IQueryable <SCIMRepresentationModel> representations, SearchSCIMRepresentationOrders order, int startIndex, int count, CancellationToken cancellationToken) { var fullPath = attrExpression.GetFullPath(); if (!MAPPING_PATH_TO_PROPERTYNAMES.ContainsKey(fullPath)) { return(null); } var representationParameter = Expression.Parameter(typeof(SCIMRepresentationModel), "rp"); var propertyName = MAPPING_PATH_TO_PROPERTYNAMES[fullPath]; var property = Expression.Property(representationParameter, MAPPING_PATH_TO_PROPERTYNAMES[fullPath]); var propertyType = typeof(SCIMRepresentationModel).GetProperty(propertyName).PropertyType; var orderBy = GetOrderByType(order, propertyType); var innerLambda = Expression.Lambda(property, new ParameterExpression[] { representationParameter }); var orderExpr = Expression.Call(orderBy, Expression.Constant(representations), innerLambda); var finalSelectArg = Expression.Parameter(typeof(IQueryable <SCIMRepresentationModel>), "f"); var finalOrderRequestBody = Expression.Lambda(orderExpr, new ParameterExpression[] { finalSelectArg }); var result = (IOrderedEnumerable <SCIMRepresentationModel>)finalOrderRequestBody.Compile().DynamicInvoke(representations); var content = result.Skip(startIndex).Take(count).ToList(); var total = await representations.CountAsync(cancellationToken); return(new SearchSCIMRepresentationsResponse(total, content.Select(r => r.ToDomain()))); }
private static MemberExpression GetCommonAttribute(SCIMAttributeExpression scimAttributeExpression, ParameterExpression parameterExpression) { var fullPath = scimAttributeExpression.GetFullPath(); if (!MAPPING_PATH_TO_PROPERTYNAMES.ContainsKey(fullPath)) { return(null); } return(Expression.Property(parameterExpression, MAPPING_PATH_TO_PROPERTYNAMES[fullPath])); }
public static LambdaExpression EvaluateOrderByMetadata(SCIMAttributeExpression attrExpression, IQueryable <SCIMRepresentation> representations, SearchSCIMRepresentationOrders order) { var fullPath = attrExpression.GetFullPath(); if (!MAPPING_PATH_TO_PROPERTYNAMES.ContainsKey(fullPath)) { return(null); } var representationParameter = Expression.Parameter(typeof(SCIMRepresentation), "rp"); var propertyName = MAPPING_PATH_TO_PROPERTYNAMES[fullPath]; var property = Expression.Property(representationParameter, MAPPING_PATH_TO_PROPERTYNAMES[fullPath]); var propertyType = typeof(SCIMRepresentation).GetProperty(propertyName).PropertyType; var orderBy = GetOrderByType(order, propertyType); var innerLambda = Expression.Lambda(property, new ParameterExpression[] { representationParameter }); var orderExpr = Expression.Call(orderBy, Expression.Constant(representations), innerLambda); var finalSelectArg = Expression.Parameter(typeof(IQueryable <SCIMRepresentation>), "f"); var finalOrderRequestBody = Expression.Lambda(orderExpr, new ParameterExpression[] { finalSelectArg }); return(finalOrderRequestBody); }
private static bool IsCommonAttribute(SCIMAttributeExpression scimAttributeExpression) { return(MAPPING_PATH_TO_PROPERTYNAMES.ContainsKey(scimAttributeExpression.GetFullPath())); }