コード例 #1
0
        /// <summary>
        /// We are using the whole entity in a new select projection. Re-bind any AzureSearchField references to JObject
        /// and ensure the entity parameter is a freshly materialized entity object from our default materializer.
        /// </summary>
        /// <param name="selectExpression">Select expression to re-bind.</param>
        /// <param name="entityParameter">Parameter that references the whole entity.</param>
        void RebindElasticFieldsAndChainProjector(Expression selectExpression, ParameterExpression entityParameter)
        {
            var projection = AzureSearchFieldsExpressionVisitor.Rebind(SourceType, Mapping, selectExpression);
            var compiled   = Expression.Lambda(projection.Item1, entityParameter, projection.Item2).Compile();

            itemProjector = h => compiled.DynamicInvoke(DefaultItemProjector(h), h);
        }
        internal static Tuple <Expression, ParameterExpression> Rebind(Type sourceType, IAzureSearchMapping mapping, Expression selector)
        {
            var parameter = Expression.Parameter(typeof(Document), "h");
            var visitor   = new AzureSearchFieldsExpressionVisitor(sourceType, parameter, mapping);

            Argument.EnsureNotNull(nameof(selector), selector);

            return(Tuple.Create(visitor.Visit(selector), parameter));
        }