Пример #1
0
 public ClonedCompiledQuery(IMaybeStatefulHandler inner, TQuery query, QueryStatistics statistics, HardCodedParameters hardcoded)
 {
     _inner      = inner;
     _query      = query;
     _statistics = statistics;
     _hardcoded  = hardcoded;
 }
        public ICompiledQuerySource Build()
        {
            if (_storeOptions.GeneratedCodeMode == TypeLoadMode.LoadFromPreBuiltAssembly)
            {
                var source = CreateFromPreBuiltType(Assembly.GetEntryAssembly());
                if (source != null)
                {
                    return(source);
                }
            }

            var assembly = new GeneratedAssembly(new GenerationRules(SchemaConstants.MartenGeneratedNamespace));


            var handlerType = determineHandlerType();

            var hardcoded           = new HardCodedParameters(_plan);
            var compiledHandlerType = buildHandlerType(assembly, handlerType, hardcoded);

            var sourceType = buildSourceType(assembly, handlerType, compiledHandlerType);

            assembly.Namespaces.Add("System");
            compileAssembly(assembly);

            return((ICompiledQuerySource)Activator.CreateInstance(sourceType.CompiledType, new object[] { hardcoded, _plan.HandlerPrototype }));
        }
Пример #3
0
        public void AssemblyType(GeneratedAssembly assembly)
        {
            assembly.Namespaces.Fill("System");

            var handlerType = determineHandlerType();

            var hardcoded           = new HardCodedParameters(_plan);
            var compiledHandlerType = buildHandlerType(assembly, handlerType, hardcoded);

            buildSourceType(assembly, handlerType, compiledHandlerType);
        }
Пример #4
0
        public ICompiledQuerySource CreateFromPreBuiltType(Assembly assembly)
        {
            var hardcoded = new HardCodedParameters(_plan);

            var sourceType = assembly.GetExportedTypes().FirstOrDefault(x => x.Name == _typeName);

            if (sourceType == null)
            {
                return(null);
            }

            return((ICompiledQuerySource)Activator.CreateInstance(sourceType, new object[] { hardcoded, _plan.HandlerPrototype }));
        }
        public ICompiledQuerySource CreateFromPreBuiltType(Assembly assembly)
        {
            var hardcoded = new HardCodedParameters(_plan);

            var sourceType = assembly.GetExportedTypes().FirstOrDefault(x => x.Name == _typeName);

            if (sourceType == null)
            {
                Console.WriteLine("Unable to find a pre-built type for compiled query with name " + _typeName);
                return(null);
            }

            return((ICompiledQuerySource)Activator.CreateInstance(sourceType, new object[] { hardcoded, _plan.HandlerPrototype }));
        }
        public ICompiledQuerySource Build()
        {
            var assembly = new GeneratedAssembly(new GenerationRules("Marten.Generated"));

            var handlerType = determineHandlerType();

            var hardcoded           = new HardCodedParameters(_plan);
            var compiledHandlerType = buildHandlerType(assembly, handlerType, hardcoded);

            var sourceType = buildSourceType(assembly, handlerType, compiledHandlerType);

            compileAssembly(assembly);



            return((ICompiledQuerySource)Activator.CreateInstance(sourceType.CompiledType, new object[] { hardcoded, _plan.HandlerPrototype }));
        }
        private GeneratedType buildHandlerType(GeneratedAssembly assembly,
                                               CompiledSourceType handlerType, HardCodedParameters hardcoded)
        {
            var queryTypeName = _plan.QueryType.Name + "CompiledQuery";
            var baseType      = determineBaseType(handlerType);
            var type          = assembly.AddType(queryTypeName, baseType);


            configureCommandMethod(type, hardcoded);

            if (handlerType == CompiledSourceType.Complex)
            {
                buildHandlerMethod(type);
            }

            return(type);
        }
Пример #8
0
        public ICompiledQuerySource Build()
        {
            var assembly = new GeneratedAssembly(new GenerationRules(SchemaConstants.MartenGeneratedNamespace));


            var handlerType = determineHandlerType();

            var hardcoded           = new HardCodedParameters(_plan);
            var compiledHandlerType = buildHandlerType(assembly, handlerType, hardcoded);

            var sourceType = buildSourceType(assembly, handlerType, compiledHandlerType);

            assembly.Namespaces.Add("System");
            compileAssembly(assembly);

            Debug.WriteLine(compiledHandlerType.SourceCode);

            return((ICompiledQuerySource)Activator.CreateInstance(sourceType.CompiledType, new object[] { hardcoded, _plan.HandlerPrototype }));
        }
        public void AssembleTypes(GeneratedAssembly assembly)
        {
            assembly.UsingNamespaces.Fill("System");

            foreach (var referencedAssembly in WalkReferencedAssemblies.ForTypes(
                         typeof(IDocumentStorage <>),
                         _plan.QueryType,
                         _plan.OutputType))
            {
                assembly.Rules.Assemblies.Fill(referencedAssembly);
            }

            var handlerType = determineHandlerType();

            var hardcoded           = new HardCodedParameters(_plan);
            var compiledHandlerType = buildHandlerType(assembly, handlerType, hardcoded);

            buildSourceType(assembly, handlerType, compiledHandlerType);
        }
        private void configureCommandMethod(GeneratedType compiledType, HardCodedParameters hardcoded)
        {
            var method = compiledType.MethodFor(nameof(IQueryHandler.ConfigureCommand));

            method.Frames.Code($"var parameters = {{0}}.{nameof(CommandBuilder.AppendWithParameters)}(@{{1}});",
                               Use.Type <CommandBuilder>(), _plan.CorrectedCommandText());

            foreach (var parameter in _plan.Parameters)
            {
                parameter.GenerateCode(method, _storeOptions);
            }

            if (hardcoded.HasTenantId)
            {
                method.Frames.Code($"{{0}}.{nameof(CommandBuilder.AddNamedParameter)}({{1}}, session.Tenant.TenantId);",
                                   Use.Type <CommandBuilder>(), TenantIdArgument.ArgName);
            }

            if (hardcoded.HasAny())
            {
                method.Frames.Code($"_hardcoded.{nameof(HardCodedParameters.Apply)}(parameters);");
            }
        }
Пример #11
0
 public StatelessCompiledQuery(IQueryHandler <TOut> inner, TQuery query, HardCodedParameters hardcoded)
 {
     _inner     = inner;
     _query     = query;
     _hardcoded = hardcoded;
 }
 public QueryOnlyIssueWithUsersCompiledQuery2026718760(Marten.Linq.QueryHandlers.IMaybeStatefulHandler inner, DocumentDbTests.Reading.Includes.end_to_end_query_with_compiled_include_Tests.IssueWithUsers query, Marten.Internal.CompiledQueries.HardCodedParameters hardcoded) : base(inner, query, hardcoded)
 {
     _inner     = inner;
     _query     = query;
     _hardcoded = hardcoded;
 }
 public QueryOnlyIssueWithUsersCompiledQuerySource2026718760(Marten.Internal.CompiledQueries.HardCodedParameters hardcoded, Marten.Linq.QueryHandlers.IMaybeStatefulHandler maybeStatefulHandler)
 {
     _hardcoded            = hardcoded;
     _maybeStatefulHandler = maybeStatefulHandler;
 }
Пример #14
0
 public DirtyTrackingUserByUsernameCompiledQuery661477123(Marten.Linq.QueryHandlers.IMaybeStatefulHandler inner, DocumentDbTests.Reading.Linq.Compiled.UserByUsername query, Marten.Linq.QueryStatistics statistics, Marten.Internal.CompiledQueries.HardCodedParameters hardcoded) : base(inner, query, statistics, hardcoded)
 {
     _inner      = inner;
     _query      = query;
     _statistics = statistics;
     _hardcoded  = hardcoded;
 }
 public NoneFindUserByAllTheThingsCompiledQuery878799577(Marten.Linq.QueryHandlers.IMaybeStatefulHandler inner, DocumentDbTests.Reading.Linq.Compiled.FindUserByAllTheThings query, Marten.Linq.QueryStatistics statistics, Marten.Internal.CompiledQueries.HardCodedParameters hardcoded) : base(inner, query, statistics, hardcoded)
 {
     _inner      = inner;
     _query      = query;
     _statistics = statistics;
     _hardcoded  = hardcoded;
 }
Пример #16
0
 public ComplexCompiledQuery(IMaybeStatefulHandler inner, TQuery query, HardCodedParameters hardcoded)
 {
     _inner     = inner;
     _query     = query;
     _hardcoded = hardcoded;
 }
Пример #17
0
 public QueryOnlyIssueByTitleWithAssigneeCompiledQuery113072566(Marten.Linq.QueryHandlers.IMaybeStatefulHandler inner, DocumentDbTests.Reading.Includes.end_to_end_query_with_compiled_include_Tests.IssueByTitleWithAssignee query, Marten.Internal.CompiledQueries.HardCodedParameters hardcoded) : base(inner, query, hardcoded)
 {
     _inner     = inner;
     _query     = query;
     _hardcoded = hardcoded;
 }
Пример #18
0
 public NoneUsersByFirstNameCompiledQuerySource314143719(Marten.Internal.CompiledQueries.HardCodedParameters hardcoded, Marten.Linq.QueryHandlers.IMaybeStatefulHandler maybeStatefulHandler)
 {
     _hardcoded            = hardcoded;
     _maybeStatefulHandler = maybeStatefulHandler;
 }
Пример #19
0
 public NoneUsersByFirstNameCompiledQuery314143719(Marten.Linq.QueryHandlers.IMaybeStatefulHandler inner, DocumentDbTests.Reading.Linq.Compiled.UsersByFirstName query, Marten.Linq.QueryStatistics statistics, Marten.Internal.CompiledQueries.HardCodedParameters hardcoded) : base(inner, query, statistics, hardcoded)
 {
     _inner      = inner;
     _query      = query;
     _statistics = statistics;
     _hardcoded  = hardcoded;
 }
 public NoneCompiledQueryTargetCompiledQuerySource9758203(Marten.Internal.CompiledQueries.HardCodedParameters hardcoded, Marten.Linq.QueryHandlers.IMaybeStatefulHandler maybeStatefulHandler)
 {
     _hardcoded            = hardcoded;
     _maybeStatefulHandler = maybeStatefulHandler;
 }
 public NoneCompiledQueryTargetCompiledQuery9758203(Marten.Linq.QueryHandlers.IMaybeStatefulHandler inner, DocumentDbTests.Reading.Linq.SimpleEqualsParserTests.CompiledQueryTarget query, Marten.Linq.QueryStatistics statistics, Marten.Internal.CompiledQueries.HardCodedParameters hardcoded) : base(inner, query, statistics, hardcoded)
 {
     _inner      = inner;
     _query      = query;
     _statistics = statistics;
     _hardcoded  = hardcoded;
 }
Пример #22
0
 public DirtyTrackingUserByUsernameCompiledQuerySource661477123(Marten.Internal.CompiledQueries.HardCodedParameters hardcoded, Marten.Linq.QueryHandlers.IMaybeStatefulHandler maybeStatefulHandler)
 {
     _hardcoded            = hardcoded;
     _maybeStatefulHandler = maybeStatefulHandler;
 }
        public ICompiledQuerySource Build(Type sourceType)
        {
            var hardcoded = new HardCodedParameters(_plan);

            return((ICompiledQuerySource)Activator.CreateInstance(sourceType, hardcoded, _plan.HandlerPrototype));
        }
 public NoneUserByUsernameWithFieldsCompiledQuerySource92089138(Marten.Internal.CompiledQueries.HardCodedParameters hardcoded, Marten.Linq.QueryHandlers.IMaybeStatefulHandler maybeStatefulHandler)
 {
     _hardcoded            = hardcoded;
     _maybeStatefulHandler = maybeStatefulHandler;
 }
 public NoneFindUserByAllTheThingsCompiledQuerySource878799577(Marten.Internal.CompiledQueries.HardCodedParameters hardcoded, Marten.Linq.QueryHandlers.IMaybeStatefulHandler maybeStatefulHandler)
 {
     _hardcoded            = hardcoded;
     _maybeStatefulHandler = maybeStatefulHandler;
 }
Пример #26
0
 public QueryOnlyUsersByFirstNameWithFieldsCompiledQuery906880034(Marten.Linq.QueryHandlers.IMaybeStatefulHandler inner, DocumentDbTests.Reading.Linq.Compiled.UsersByFirstNameWithFields query, Marten.Linq.QueryStatistics statistics, Marten.Internal.CompiledQueries.HardCodedParameters hardcoded) : base(inner, query, statistics, hardcoded)
 {
     _inner      = inner;
     _query      = query;
     _statistics = statistics;
     _hardcoded  = hardcoded;
 }
Пример #27
0
 public QueryOnlyUsersByFirstNameWithFieldsCompiledQuerySource906880034(Marten.Internal.CompiledQueries.HardCodedParameters hardcoded, Marten.Linq.QueryHandlers.IMaybeStatefulHandler maybeStatefulHandler)
 {
     _hardcoded            = hardcoded;
     _maybeStatefulHandler = maybeStatefulHandler;
 }
Пример #28
0
 public NoneTargetPaginationQueryCompiledQuery323866534(Marten.Linq.QueryHandlers.IMaybeStatefulHandler inner, DocumentDbTests.Reading.Linq.invoking_query_with_statistics.TargetPaginationQuery query, Marten.Linq.QueryStatistics statistics, Marten.Internal.CompiledQueries.HardCodedParameters hardcoded) : base(inner, query, statistics, hardcoded)
 {
     _inner      = inner;
     _query      = query;
     _statistics = statistics;
     _hardcoded  = hardcoded;
 }
Пример #29
0
 public QueryOnlyIssueByTitleWithAssigneeCompiledQuerySource113072566(Marten.Internal.CompiledQueries.HardCodedParameters hardcoded, Marten.Linq.QueryHandlers.IMaybeStatefulHandler maybeStatefulHandler)
 {
     _hardcoded            = hardcoded;
     _maybeStatefulHandler = maybeStatefulHandler;
 }
Пример #30
0
 public NoneFindJsonUsersByUsernameCompiledQuerySource1607037309(Marten.Internal.CompiledQueries.HardCodedParameters hardcoded, Marten.Linq.QueryHandlers.IMaybeStatefulHandler maybeStatefulHandler)
 {
     _hardcoded            = hardcoded;
     _maybeStatefulHandler = maybeStatefulHandler;
 }