internal static new Projection Rebind(ParameterExpression parameter, string prefix, IElasticMapping mapping, Expression selector)
 {
     var visitor = new ProjectionExpressionVisitor(parameter, prefix, mapping);
     Argument.EnsureNotNull("selector", selector);
     var materialization = visitor.Visit(selector);
     return new Projection(visitor.fieldNames, materialization);
 }
        /// <summary>
        /// We are using just some properties of the entity. Rewrite the properties as JObject field lookups and
        /// record all the field names used to ensure we only select those.
        /// </summary>
        /// <param name="selectExpression">Select expression to re-bind.</param>
        private void RebindPropertiesAndElasticFields(Expression selectExpression)
        {
            var projection = ProjectionExpressionVisitor.Rebind(projectionParameter, prefix, mapping, selectExpression);
            var compiled   = Expression.Lambda(projection.Materialization, projectionParameter).Compile();

            itemProjector = h => compiled.DynamicInvoke(h);
            searchRequest.Fields.AddRange(projection.FieldNames);
            finalItemType = selectExpression.Type;
        }
示例#3
0
        internal static new Projection Rebind(ParameterExpression parameter, string prefix, IElasticMapping mapping, Expression selector)
        {
            var visitor = new ProjectionExpressionVisitor(parameter, prefix, mapping);

            Argument.EnsureNotNull("selector", selector);
            var materialization = visitor.Visit(selector);

            return(new Projection(visitor.fieldNames, materialization));
        }