public async Task NavigationProperty() { await using var database = await sqlInstance.Build(); var context = database.Context; var child = new MappingChild(); var parent = new MappingParent { Property = "value" }; child.Parent = parent; await database.AddData(child, parent); var expression = Mapper.NavigationExpression <MappingContext, MappingChild, MappingParent>("Parent"); Func <ResolveEfFieldContext <MappingContext, MappingChild>, MappingParent> compile = expression.Compile(); var result = compile( new ResolveEfFieldContext <MappingContext, MappingChild> { DbContext = context, Source = child }); await Verifier.Verify( new { expression, result }); }
public async Task Resolve() { await using var database = await sqlInstance.Build(); var parent = new MappingParent(); var child = new MappingChild { Parent = parent }; await database.AddDataUntracked(child, parent); var services = new ServiceCollection(); services.AddSingleton <MappingQuery>(); EfGraphQLConventions.RegisterInContainer(services, _ => database.NewDbContext(), model: sqlInstance.Model); await using var provider = services.BuildServiceProvider(); var mappingQuery = provider.GetRequiredService <MappingQuery>(); var resolve = await(Task <IEnumerable <MappingChild> >) mappingQuery.Fields .Single(x => x.Name == "children") .Resolver ! .Resolve(new ResolveFieldContext()) !; await Verify(resolve); }
public async Task Resolve() { await using var database = await sqlInstance.Build(); var context = database.Context; var parent = new MappingParent(); var child = new MappingChild { Parent = parent }; await database.AddDataUntracked(child, parent); var graphQlService = new EfGraphQLService <MappingContext>(context.Model, _ => context); var resolve = await(Task <IEnumerable <MappingChild> >) new MappingQuery(graphQlService).Fields .Single(x => x.Name == "children") .Resolver .Resolve(new ResolveFieldContext()); await Verifier.Verify(resolve); }