public virtual Expression <Func <ValueBuffer, object> > CreateMaterializer(
            IEntityType entityType,
            FindExpression findExpression,
            Func <IProperty, FindExpression, int> projectionAdder)
        {
            Check.NotNull(entityType, nameof(entityType));
            Check.NotNull(findExpression, nameof(findExpression));
            Check.NotNull(projectionAdder, nameof(projectionAdder));

            var valueBufferParameter
                = Expression.Parameter(typeof(ValueBuffer), "valueBuffer");

            var indexMap      = new int[entityType.PropertyCount()];
            var propertyIndex = 0;

            foreach (var property in entityType.GetProperties())
            {
                indexMap[propertyIndex++]
                    = projectionAdder(property, findExpression);
            }

            var materializer
                = _entityMaterializerSource
                  .CreateMaterializeExpression(
                      entityType, valueBufferParameter, indexMap);

            return(Expression.Lambda <Func <ValueBuffer, object> >(materializer, valueBufferParameter));
        }
        private Shaper CreateShaper(Type elementType, IEntityType entityType, FindExpression findExpression)
        {
            Shaper shaper;

            var materializer
                = _materializerFactory
                  .CreateMaterializer(
                      entityType,
                      findExpression,
                      (p, se) =>
                      se.AddToProjection(
                          _annotationsProvider.For(p).FieldName,
                          p)
                      ).Compile();

            shaper
                = (Shaper)_createEntityShaperMethodInfo.MakeGenericMethod(elementType)
                  .Invoke(null, new object[]
            {
                entityType.DisplayName(),
                QueryModelVisitor.QueryCompilationContext.IsTrackingQuery,
                entityType.FindPrimaryKey(),
                materializer
            });

            return(shaper);
        }
        public Expression VisitFind(FindExpression findExpression)
        {
            VisitCollection(findExpression.Collection);

            if (findExpression.Projection.Any())
            {
                VisitProjection(findExpression.Projection);
            }

            return(findExpression);
        }
        public Expression VisitFind([NotNull] FindExpression findExpression)
        {
            Check.NotNull(findExpression, nameof(findExpression));

            VisitCollection(findExpression.Collection);

            if (findExpression.Projection.Any())
            {
                VisitProjection(findExpression.Projection);
            }

            return(findExpression);
        }
Esempio n. 5
0
        private void SmartSay()
        {
            InterpreterContext context = new InterpreterContext(CommandText, this);
            string             start   = context.PartsOfMessage()[0];

            Shell.Models.SmartShellExpressions.Expression expression = null;

            if (start.ToLower() == "open")
            {
                expression = new OpenExpression();
            }
            else if (start.ToLower() == "copy")
            {
                expression = new CopyExpression();
            }
            else if (start.ToLower() == "delete")
            {
                expression = new DeleteExpression();
            }
            else if (start.ToLower() == "find")
            {
                expression = new FindExpression();
            }

            if (expression != null)
            {
                try
                { expression.Interpret(context); }
                catch (Exception e) { MessageBox.Show(e.ToString()); }
                if (expression.GetItemsToShow() != null)
                {
                    Files = expression.GetItemsToShow();
                }
            }
            else
            {
                MessageBox.Show("Invalid command");
            }
            try
            {
                Refresh();
            }
            catch  { }
        }
Esempio n. 6
0
        /// <summary>
        /// Finds the script node by the specified expression at the specified category and its children.
        /// </summary>
        private static ScriptData FindScriptData(CategoryData category, FindExpression findExpression)
        {
            foreach (ScriptData scriptData in category.Items)
            {
                if (findExpression(scriptData))
                {
                    return(scriptData);
                }

                if (scriptData is CategoryData)
                {
                    ScriptData data = FindScriptData((CategoryData)scriptData, findExpression);
                    if (data != null)
                    {
                        return(data);
                    }
                }
            }

            return(null);
        }
Esempio n. 7
0
 public IBsonQueryGenerator Create(FindExpression findExpression)
 => new BsonQueryGenerator(_bsonCommandBuilderFactory, findExpression);
 public BsonQueryGenerator(IBsonCommandBuilderFactory bsonCommandBuilderFactory,
                           FindExpression findExpression)
 {
     _bsonCommandBuilderFactory = bsonCommandBuilderFactory;
     _findExpression            = findExpression;
 }
Esempio n. 9
0
 public IValueBufferFromBsonShaper Create(FindExpression findExpression)
 => new ValueBufferFromBsonShaper(findExpression);
Esempio n. 10
0
 public ValueBufferFromBsonShaper(FindExpression findExpression)
 {
     _findExpression = findExpression;
 }
Esempio n. 11
0
        public ValueBufferFromBsonShaper([NotNull] FindExpression findExpression)
        {
            Check.NotNull(findExpression, nameof(findExpression));

            _findExpression = findExpression;
        }