private async Task <T> QueryInternal <T>(Guid id) { using (var session = _DocumentStore.LightweightSession()) { return(await session.LoadAsync <T>(id)); } }
public string SourceCodeForCompiledQuery(Type type) { if (!type.Closes(typeof(ICompiledQuery <,>))) { throw new ArgumentOutOfRangeException(nameof(type), "Not a compiled query type"); } var assembly = new GeneratedAssembly(new GenerationRules(SchemaConstants.MartenGeneratedNamespace)); using var session = _store.LightweightSession(); var plan = QueryCompiler.BuildPlan((IMartenSession)session, type, _store.Options); var builder = new CompiledQuerySourceBuilder(plan, _store.Options); var(sourceType, handlerType) = builder.AssemblyType(assembly); return(assembly.GenerateCode()); }