Ejemplo n.º 1
0
        public List <DuplicateRuleCondition> Query(Func <QueryDescriptor <DuplicateRuleCondition>, QueryDescriptor <DuplicateRuleCondition> > container)
        {
            QueryDescriptor <DuplicateRuleCondition> q = container(QueryDescriptorBuilder.Build <DuplicateRuleCondition>());

            return(_duplicateRuleConditionRepository.Query(q)?.ToList());
        }
        public async Task Interface_Two_Cases_3()
        {
            // arrange
            var path = HotChocolate.Path.New("root");

            DocumentNode document = Utf8GraphQLParser.Parse(
                @"
                query getHero {
                    hero {
                        ...Hero
                    }
                }

                fragment Hero on Character {
                    ...HasName
                    ...SomeDroid
                    ...SomeHuman
                }

                fragment SomeDroid on Droid {
                    ...HasName
                    primaryFunction
                }

                fragment SomeHuman on Human {
                    ...HasName
                    homePlanet
                }

                fragment HasName on Character {
                    name
                }
                ");

            var operation = document.Definitions
                            .OfType <OperationDefinitionNode>()
                            .First();

            var field = operation.SelectionSet.Selections
                        .OfType <FieldNode>()
                        .First();

            var query = new QueryDescriptor(
                "Simple_Query",
                "Foo.Bar.Ns",
                "1234",
                "12345",
                new byte[] { 1, 2, 3 },
                document);

            var schema = SchemaBuilder.New()
                         .AddDocumentFromString(FileResource.Open("StarWars.graphql"))
                         .Use(next => context => Task.CompletedTask)
                         .Create();

            var context = new ModelGeneratorContext(
                schema,
                query,
                "StarWarsClient",
                "Foo.Bar.Ns");

            var character = schema.GetType <InterfaceType>("Character");

            // act
            var generator = new InterfaceModelGenerator();

            generator.Generate(
                context,
                operation,
                character,
                character,
                field,
                context.CollectFields(character, field.SelectionSet, path),
                path);

            // assert
            var typeLookup = new TypeLookup(
                LanguageVersion.CSharp_8_0,
                CollectFieldsVisitor.MockLookup(document, context.FieldTypes));

            string output = await WriteAllAsync(context.Descriptors, typeLookup);

            output.MatchSnapshot();
        }
Ejemplo n.º 3
0
        public List <EventMessage> Query(Func <QueryDescriptor <EventMessage>, QueryDescriptor <EventMessage> > container)
        {
            QueryDescriptor <EventMessage> q = container(QueryDescriptorBuilder.Build <EventMessage>());

            return(_eventMessageRepository.Query(q)?.ToList());
        }
Ejemplo n.º 4
0
        public List <Domain.Organization> Query(Func <QueryDescriptor <Domain.Organization>, QueryDescriptor <Domain.Organization> > container)
        {
            QueryDescriptor <Domain.Organization> q = container(QueryDescriptorBuilder.Build <Domain.Organization>());

            return(_organizationRepository.Query(q)?.ToList());
        }
Ejemplo n.º 5
0
        public List <Domain.Role> Query(Func <QueryDescriptor <Domain.Role>, QueryDescriptor <Domain.Role> > container)
        {
            QueryDescriptor <Domain.Role> q = container(QueryDescriptorBuilder.Build <Domain.Role>());

            return(_roleRepository.Query(q)?.ToList());
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 查询记录数
 /// </summary>
 /// <param name="q">上下文</param>
 /// <returns></returns>
 public long Count(QueryDescriptor <OrganizationBase> q)
 {
     return(_repository.Count(q));
 }
Ejemplo n.º 7
0
 public virtual bool Exists(QueryDescriptor <T> context)
 {
     return(_repository.Exists(context));
 }
Ejemplo n.º 8
0
        public List <SystemUser> Query(Func <QueryDescriptor <SystemUser>, QueryDescriptor <SystemUser> > container)
        {
            QueryDescriptor <SystemUser> q = container(QueryDescriptorBuilder.Build <SystemUser>());

            return(_repository.Query(q)?.ToList());
        }
Ejemplo n.º 9
0
        public List <LocalizedLabel> Query(Func <QueryDescriptor <LocalizedLabel>, QueryDescriptor <LocalizedLabel> > container)
        {
            QueryDescriptor <LocalizedLabel> q = container(QueryDescriptorBuilder.Build <LocalizedLabel>());

            return(_localizedLabelRepository.Query(q)?.ToList());
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Handles the custom message. The message will have the query information
        /// </summary>
        /// <param name="activity">The activity.</param>
        /// <returns></returns>
        private static async Task <string> HandleCustomMessage(Activity activity)
        {
            //Get natural language processed by LUIS


            var luisResponse = await LUISMetalQueryClient.ParseUserInput(activity.Text);

            var responseMessage = string.Empty;

            // what is the lowest for gold in 20/10/2017
            int isDateRange = 0;
            var metals      = luisResponse.entities.Where(x => x.type == "metal").Select(x => x.entity).ToList();
            var numbers     = luisResponse.entities.Where(x => x.type == "builtin.number").Select(x => x.resolution.value).ToList();

            List <string> dates = new List <string>();

            dates = luisResponse.entities.Where(x => x.type == "builtin.datetimeV2.date").Select(x => x.entity).ToList();

            if (dates.Count == 0)
            {
                dates       = luisResponse.entities.Where(x => x.type == "builtin.datetimeV2.daterange").Select(x => x.entity).ToList();
                isDateRange = 1;
            }

            List <DateTime> parsedDates = new List <DateTime>();


            if (isDateRange == 0)
            {
                parsedDates = dates.Select(x => DateTime.Parse(x)).ToList();
            }
            else
            {
                parsedDates = dates.Select(x => x.Length > 4  ? DateTime.Parse(x) : new DateTime(int.Parse(x), 1, 1)).ToList();
            }

            var isPriceOriented = luisResponse.entities.Any(x => x.type == "cost");
            var requestsLowest  = luisResponse.entities.Any(x => x.type == "lowest");
            var requestsHighest = luisResponse.entities.Any(x => x.type == "highest");
            var requestAverage  = luisResponse.entities.Any(x => x.type == "average");

            DateTime maxDate;
            DateTime minDate;

            using (var dataContext = new botEntities())
            {
                maxDate = dataContext.prices.Max(x => x.date);
                minDate = dataContext.prices.Min(x => x.date);
            }

            switch (luisResponse.intents[0].intent)
            {
            case "Greeting":
                responseMessage = "Hi there, how can I help you?";
                return(responseMessage);


            case "Metal Sales":
                var showHelp = luisResponse.entities.Any(x => x.type == "help" || x.type == "greeting");
                // should check intents not entities

                if (showHelp)
                {
                    responseMessage = $"Hi I am **Metal Bot**, I can assist you with sales of Metal.  {Environment.NewLine}You can ask me something like 'What is the average sale for 2010?' or 'What was the highest sale in USA,Widwest'.  {Environment.NewLine}**Give me a try!**  {Environment.NewLine}![logo](https://pbs.twimg.com/profile_images/803953567686131712/8qIowSgm_400x400.jpg)";
                    return(responseMessage);
                }


                if (parsedDates.Any() && parsedDates.All(x => !(minDate <= x && maxDate >= x)))
                {
                    responseMessage = $"Sorry I only have data from {minDate:MMMM yyyy} to {maxDate:MMMM yyyy}";
                    return(responseMessage);
                }

                PriceFilterType priceFilter;
                if (requestsLowest)    //Intentionally done first, in case both exist i.e worst expensive
                {
                    priceFilter = PriceFilterType.Least;
                }
                else if (requestsHighest)
                {
                    priceFilter = PriceFilterType.Most;
                }
                else if (requestAverage)
                {
                    priceFilter = PriceFilterType.Average;
                }
                else
                {
                    priceFilter = PriceFilterType.None;
                }

                //Question 'What is the cost of gold in January 2015' has 2015 as part of date and number
                numbers.RemoveAll(x => x.Length == 4 && dates.Any(d => d.Contains(x)));

                var hasMonths = false;
                if (dates.Any())
                {
                    hasMonths = dates.Any(x => x.Contains('-') || x.Length > 4);
                }

                var number = 1;
                //TODO: What if user gives more than one number
                if (numbers.Any())
                {
                    number = int.Parse(numbers.First());
                }

                var queryDescriptor = new QueryDescriptor(
                    isPriceOriented,
                    metals,
                    parsedDates,
                    hasMonths ? TimelineConstraintLimit.Month : TimelineConstraintLimit.Year,
                    priceFilter,
                    !dates.Any(),
                    number
                    );
                var result = QueryProcessor.Process(queryDescriptor);

                var failedToEvaluate = EvaluateResultStatus(out responseMessage, result.QueryResultType);
                if (failedToEvaluate)
                {
                    return(responseMessage);
                }

                if (result.Average != 0)
                {
                    if (hasMonths)
                    {
                        responseMessage = string.Format("The average price of {0} for {1} {2} is ${3} ", metals[0], parsedDates[0].ToString("MMMM"), parsedDates[0].Year, result.Average.ToString());
                    }
                    else
                    {
                        responseMessage = string.Format("The average price of {0} for {1} is ${2} ", metals[0], parsedDates[0].Year, result.Average.ToString());
                    }
                }
                else
                {
                    responseMessage = FormatResult(result.Prices.ToList(), number);
                }


                break;

            case "Price":
                //what is the price of copper in April 2017?
                break;

            case "Help":
                responseMessage = "I can help you with finding the price of a metal in a given month, the average price over a year, the highest price and the lowest price.";
                break;

            case "None":
                responseMessage = "Sorry, I don't understand, perhaps try something like \"What was the price of gold in April 2017?\"";
                break;
            }
            return(responseMessage);
        }
Ejemplo n.º 11
0
        public PagedList <Domain.Solution> QueryPaged(Func <QueryDescriptor <Domain.Solution>, QueryDescriptor <Domain.Solution> > container)
        {
            QueryDescriptor <Domain.Solution> q = container(QueryDescriptorBuilder.Build <Domain.Solution>());

            return(_solutionRepository.QueryPaged(q));
        }
Ejemplo n.º 12
0
        public List <Domain.Module> Query(Func <QueryDescriptor <Domain.Module>, QueryDescriptor <Domain.Module> > container)
        {
            QueryDescriptor <Domain.Module> q = container(QueryDescriptorBuilder.Build <Domain.Module>());

            return(_repository.Query(q));
        }
Ejemplo n.º 13
0
        public Privilege Find(Func <QueryDescriptor <Privilege>, QueryDescriptor <Privilege> > container)
        {
            QueryDescriptor <Privilege> q = container(QueryDescriptorBuilder.Build <Privilege>());

            return(_privilegeRepository.Find(q));
        }
Ejemplo n.º 14
0
        public ElasticsearchDynamicValue[] Search(ElasticDocument objectToSearch, SearchCriteria p_criteria)
        //public IEnumerable<ElasticDocument> Search(ElasticDocument objectToSearch)
        {
            ElasticsearchDynamicValue[] response = null;
            QueryContainer queryContainer = new QueryContainer();

           /*
            var queryMatchName = new MatchQueryDescriptor<ElasticDocument>().OnField("_search.name").Query(objectToSearch.Search.Name);
            var queryMatchDescription = new MatchQueryDescriptor<ElasticDocument>().OnField("_search.description").Query(objectToSearch.Search.Description);
            var queryMatchOwner = new MatchQueryDescriptor<ElasticDocument>().OnField("_search.owner").Query(objectToSearch.Search.Owner);

            var queryTermName = new TermQueryDescriptor<ElasticDocument>().OnField("_search.name").Value(objectToSearch.Search.Name);
            var queryTermDescription = new TermQueryDescriptor<ElasticDocument>().OnField("_search.description").Value(objectToSearch.Search.Description);
            var queryTermOwner = new TermQueryDescriptor<ElasticDocument>().OnField("_search.owner").Value(objectToSearch.Search.Owner);
            */

            if (p_criteria.Condition.Equals(SHOULD) && p_criteria.QueryType.Equals(MATCH))
                queryContainer = new QueryDescriptor<ElasticDocument>().Bool(b => b.
                            Should(s => s.Match(m => m.OnField("_search.name").Query(objectToSearch.Search.Name)) ||
                                        s.Match(m => m.OnField("_search.description").Query(objectToSearch.Search.Description)) ||
                                        s.Match(m => m.OnField("_search.owner").Query(objectToSearch.Search.Owner))));

            if (p_criteria.Condition.Equals(MUST) && p_criteria.QueryType.Equals(MATCH))
                queryContainer = new QueryDescriptor<ElasticDocument>().Bool(b => b.
                            Must(s => s.Match(m => m.OnField("_search.name").Query(objectToSearch.Search.Name)) &&
                                      s.Match(m => m.OnField("_search.description").Query(objectToSearch.Search.Description)) &&
                                      s.Match(m => m.OnField("_search.owner").Query(objectToSearch.Search.Owner))));

            if (p_criteria.Condition.Equals(SHOULD) && p_criteria.QueryType.Equals(TERM))
                queryContainer = new QueryDescriptor<ElasticDocument>().Bool(b => b.
                        Should(s => s.Term(m => m.OnField("_search.name").Value(objectToSearch.Search.Name)) ||
                                    s.Term(m => m.OnField("_search.description").Value(objectToSearch.Search.Description)) ||
                                    s.Term(m => m.OnField("_search.owner").Value(objectToSearch.Search.Owner))));

            if (p_criteria.Condition.Equals(MUST) && p_criteria.QueryType.Equals(TERM))
                queryContainer = new QueryDescriptor<ElasticDocument>().Bool(b => b.
                            Must(s => s.Term(m => m.OnField("_search.name").Value(objectToSearch.Search.Name)) &&
                                      s.Term(m => m.OnField("_search.description").Value(objectToSearch.Search.Description)) &&
                                      s.Term(m => m.OnField("_search.owner").Value(objectToSearch.Search.Owner))));
            
            var searchDescriptor = new SearchDescriptor<ElasticDocument>().
                Query(queryContainer);

            var request = clientElasticNest.Serializer.Serialize(searchDescriptor);

            var results = clientElasticNest.Raw.Search(request);

            int total_hits = (int)results.Response[HITS][TOTAL_HITS];
            ElasticsearchDynamicValue hits = results.Response[HITS][HITS];

            if (total_hits > 0)
                response = new ElasticsearchDynamicValue[total_hits];
            else
                response = new ElasticsearchDynamicValue[0];

            for (int i = 0; i < total_hits; i++)
            {
                response[i] = hits[i];
            }

            return response;
            
        }
Ejemplo n.º 15
0
 public virtual T Find(QueryDescriptor <T> q)
 {
     return(_repository.Find(q));
 }
Ejemplo n.º 16
0
        public List <FilterRule> Query(Func <QueryDescriptor <FilterRule>, QueryDescriptor <FilterRule> > container)
        {
            QueryDescriptor <FilterRule> q = container(QueryDescriptorBuilder.Build <FilterRule>());

            return(_filterRuleRepository.Query(q)?.ToList());
        }
Ejemplo n.º 17
0
 public virtual List <T> Query(QueryDescriptor <T> q)
 {
     return(_repository.Query(q));
 }
Ejemplo n.º 18
0
        public List <OrganizationBase> Query(Func <QueryDescriptor <OrganizationBase>, QueryDescriptor <OrganizationBase> > container)
        {
            QueryDescriptor <OrganizationBase> q = container(QueryDescriptorBuilder.Build <OrganizationBase>());

            return(_repository.Query(q));
        }
Ejemplo n.º 19
0
 /// <summary>
 /// 查询记录
 /// </summary>
 /// <param name="q">上下文</param>
 /// <returns></returns>
 public virtual PagedList <T> QueryPaged(QueryDescriptor <T> q)
 {
     return(_repository.QueryPaged(q));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// 查询记录
 /// </summary>
 /// <param name="q">上下文</param>
 /// <returns></returns>
 public List <OrganizationBase> Query(QueryDescriptor <OrganizationBase> q)
 {
     return(_repository.Query(q));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// 获取前X条记录
 /// </summary>
 /// <param name="q"></param>
 /// <returns></returns>
 public virtual List <T> Top(QueryDescriptor <T> q)
 {
     return(_repository.Top(q));
 }
        public async Task Union_Inline_Fragments_Skip_One_Type()
        {
            // arrange
            var path = HotChocolate.Path.New("root");

            DocumentNode document = Utf8GraphQLParser.Parse(
                @"
                query search {
                    search(text: ""foo"") {
                        ... on Human {
                            homePlanet
                        }
                        ... on Droid {
                            primaryFunction
                        }
                    }
                }
                ");

            var operation = document.Definitions
                            .OfType <OperationDefinitionNode>()
                            .First();

            var field = operation.SelectionSet.Selections
                        .OfType <FieldNode>()
                        .First();

            var query = new QueryDescriptor(
                "Simple_Query",
                "Foo.Bar.Ns",
                "1234",
                "12345",
                new byte[] { 1, 2, 3 },
                document);

            var schema = SchemaBuilder.New()
                         .AddDocumentFromString(FileResource.Open("StarWars.graphql"))
                         .Use(next => context => Task.CompletedTask)
                         .Create();

            var context = new ModelGeneratorContext(
                schema,
                query,
                "StarWarsClient",
                "Foo.Bar.Ns");

            var character = schema.GetType <UnionType>("SearchResult");

            // act
            var generator = new UnionModelGenerator();

            generator.Generate(
                context,
                operation,
                character,
                character,
                field,
                context.CollectFields(character, field.SelectionSet, path),
                path);

            // assert
            var typeLookup = new TypeLookup(
                LanguageVersion.CSharp_8_0,
                CollectFieldsVisitor.MockLookup(document, context.FieldTypes));

            string output = await WriteAllAsync(context.Descriptors, typeLookup);

            output.MatchSnapshot();
        }
Ejemplo n.º 23
0
 /// <summary>
 /// 查询记录数
 /// </summary>
 /// <param name="q">上下文</param>
 /// <returns></returns>
 public virtual long Count(QueryDescriptor <T> q)
 {
     return(_repository.Count(q));
 }
Ejemplo n.º 24
0
        /// <summary>
        /// Processes the query.
        /// </summary>
        public static QueryResults Process(QueryDescriptor query)
        {
            var queryResult = new QueryResults();

#pragma warning disable 618
            var predicate = PredicateBuilder.False <price>();
#pragma warning restore 618

            if (!query.IsCostFocused && !query.HasPriceFilter)
            {
                queryResult.SetResultState(QueryResultType.NonCostFocused);
                return(queryResult);
            }

            if (!query.HasMetalNames && !query.HasPriceFilter)
            {
                queryResult.SetResultState(QueryResultType.NoMetalSpecified);
                return(queryResult);
            }

            //botEntities is a EntityDataContext
            var dataContext = new botEntities();
            //What is the price of gold
            //What is the current price of gold
            //What is the price of gold now
            //What is the price of gold today
            //  Current price

            //What is the price of gold in 2015
            //What is the price of gold in January 2015
            if (!query.HasPriceFilter)
            {
                foreach (string keyword in query.MetalNames)
                {
                    string temp = keyword;
                    predicate = predicate.Or(p => p.metal.name.Equals(temp));
                }

                if (!query.HasTimeConstraints || query.UseCurrentTimeLine)
                {
                    query.SetTimelineToCurrent();
                }

                foreach (var time in query.TimelineConstraints)
                {
                    predicate = query.TimeLineConstraintLimit == TimelineConstraintLimit.Month ? predicate.And(p => (p.date.Year == time.Year && p.date.Month == time.Month)) : predicate.And(p => (p.date.Year == time.Year));
                }

                queryResult.Prices = dataContext.prices.AsExpandable().Where(predicate);
                queryResult.SetResultState(QueryResultType.Ok);
                return(queryResult);
            }

            //When was gold most expensive
            //When was gold cheapest
            //  Open specific metal filter
            //When was gold most expensive in 2015
            //  Restricted specific metal filter
            //What metal was the most expensive in 2015
            //Which metal was the cheapest in 2015
            if (query.HasPriceFilter && query.MetalNames.Count <= 1)
            {
                var keyword = query.MetalNames.FirstOrDefault();
                if (keyword != null)
                {
                    predicate = predicate.Or(p => p.metal.name.Equals(keyword));
                }

                foreach (var time in query.TimelineConstraints)
                {
                    predicate = query.TimeLineConstraintLimit == TimelineConstraintLimit.Month ? predicate.And(p => (p.date.Year == time.Year && p.date.Month == time.Month)) : predicate.And(p => (p.date.Year == time.Year));
                }

                if (query.PriceFilterType == PriceFilterType.Least)
                {
                    queryResult.Prices =
                        dataContext.prices.AsExpandable()
                        .Where(predicate)
                        .OrderBy(t => t.price1)
                        .Take(query.NumberConstraint);
                }
                else
                {
                    queryResult.Prices =
                        dataContext.prices.AsExpandable()
                        .Where(predicate)
                        .OrderByDescending(t => t.price1)
                        .Take(query.NumberConstraint);
                }
                queryResult.SetResultState(QueryResultType.Ok);
                return(queryResult);
            }

            queryResult.SetResultState(QueryResultType.Inconclusive);
            return(queryResult);
        }
Ejemplo n.º 25
0
 private IQueryResponse<Tweet> ExecuteDsl(QueryDescriptor<Tweet> query, int maxDocuments)
 {
     return _client.Search<Tweet>(s => s.Query(query).Size(maxDocuments));
 }
Ejemplo n.º 26
0
        public List <EntityPlugin> Query(Func <QueryDescriptor <EntityPlugin>, QueryDescriptor <EntityPlugin> > container)
        {
            QueryDescriptor <EntityPlugin> q = container(QueryDescriptorBuilder.Build <EntityPlugin>());

            return(_entityPluginRepository.Query(q)?.ToList());
        }
Ejemplo n.º 27
0
        public async Task Object_List_With_Fragment()
        {
            // arrange
            var path = HotChocolate.Path.New("root");

            DocumentNode document = Utf8GraphQLParser.Parse(
                @"
                query getBars {
                    foo {
                        bars {
                            baz
                        }
                    }
                }
                ");

            var operation = document.Definitions
                            .OfType <OperationDefinitionNode>()
                            .First();

            var field = operation.SelectionSet.Selections
                        .OfType <FieldNode>()
                        .First();

            var query = new QueryDescriptor(
                "Simple_Query",
                "Foo.Bar.Ns",
                "1234",
                "12345",
                new byte[] { 1, 2, 3 },
                document);

            var schema = SchemaBuilder.New()
                         .AddDocumentFromString(
                @"
                    type Query {
                        foo: Foo
                    }

                    type Foo {
                        bars: [Bar]
                    }

                    type Bar {
                        baz: String
                    }
                    ")
                         .Use(next => context => Task.CompletedTask)
                         .Create();

            var context = new ModelGeneratorContext(
                schema,
                query,
                "StarWarsClient",
                "Foo.Bar.Ns");

            var bar = schema.GetType <ObjectType>("Foo");

            // act
            var generator = new ObjectModelGenerator();

            generator.Generate(
                context,
                operation,
                bar,
                bar,
                field,
                context.CollectFields(bar, field.SelectionSet, path),
                path);

            // assert
            var typeLookup = new TypeLookup(
                LanguageVersion.CSharp_8_0,
                CollectFieldsVisitor.MockLookup(document, context.FieldTypes));

            string output = await WriteAllAsync(context.Descriptors, typeLookup);

            output.MatchSnapshot();
        }
        public List <RoleObjectAccessEntityPermission> Query(Func <QueryDescriptor <RoleObjectAccessEntityPermission>, QueryDescriptor <RoleObjectAccessEntityPermission> > container)
        {
            QueryDescriptor <RoleObjectAccessEntityPermission> q = container(QueryDescriptorBuilder.Build <RoleObjectAccessEntityPermission>());

            return(_roleObjectAccessEntityPermissionRepository.Query(q)?.ToList());
        }
Ejemplo n.º 29
0
        public async Task Object_With_Fragment()
        {
            // arrange
            var path = HotChocolate.Path.New("root");

            DocumentNode document = Utf8GraphQLParser.Parse(
                @"
                query search {
                    droid(id: ""foo"") {
                        ... SomeDroid
                    }
                }

                fragment SomeDroid on Droid {
                    name
                }
                ");

            var operation = document.Definitions
                            .OfType <OperationDefinitionNode>()
                            .First();

            var field = operation.SelectionSet.Selections
                        .OfType <FieldNode>()
                        .First();

            var query = new QueryDescriptor(
                "Simple_Query",
                "Foo.Bar.Ns",
                "1234",
                "12345",
                new byte[] { 1, 2, 3 },
                document);

            var schema = SchemaBuilder.New()
                         .AddDocumentFromString(FileResource.Open("StarWars.graphql"))
                         .Use(next => context => Task.CompletedTask)
                         .Create();

            var context = new ModelGeneratorContext(
                schema,
                query,
                "StarWarsClient",
                "Foo.Bar.Ns");

            var droid = schema.GetType <ObjectType>("Droid");

            // act
            var generator = new ObjectModelGenerator();

            generator.Generate(
                context,
                operation,
                droid,
                droid,
                field,
                context.CollectFields(droid, field.SelectionSet, path),
                path);

            // assert
            var typeLookup = new TypeLookup(
                LanguageVersion.CSharp_8_0,
                CollectFieldsVisitor.MockLookup(document, context.FieldTypes));

            string output = await WriteAllAsync(context.Descriptors, typeLookup);

            output.MatchSnapshot();
        }
Ejemplo n.º 30
0
        public PagedList <BusinessUnit> QueryPaged(Func <QueryDescriptor <BusinessUnit>, QueryDescriptor <BusinessUnit> > container)
        {
            QueryDescriptor <BusinessUnit> q = container(QueryDescriptorBuilder.Build <BusinessUnit>());

            return(_businessUnitRepository.QueryPaged(q));
        }
Ejemplo n.º 31
0
        public PagedList <SystemUser> QueryPaged(Func <QueryDescriptor <SystemUser>, QueryDescriptor <SystemUser> > container)
        {
            QueryDescriptor <SystemUser> q = container(QueryDescriptorBuilder.Build <SystemUser>());

            return(_repository.QueryPaged(q));
        }
Ejemplo n.º 32
0
        public List <ProcessStage> Query(Func <QueryDescriptor <ProcessStage>, QueryDescriptor <ProcessStage> > container)
        {
            QueryDescriptor <ProcessStage> q = container(QueryDescriptorBuilder.Build <ProcessStage>());

            return(_processStageRepository.Query(q)?.ToList());
        }
Ejemplo n.º 33
-1
		private static QueryContainer CreatePermissionsFilter(
			Guid CurrentUserId, 
			List<Guid> usersToSearch, 
			bool searchUnassigned, 
			QueryDescriptor<ParentRecord> filter
		)
		{
			return filter.Bool(c => c
				.Should(
					s => s.Terms(p => p.AssignedUsers.First(), usersToSearch),
					s => s.Term(p => p.OverrideUsers, CurrentUserId),	
					s => s.Term(p => p.Unassigned, "true"),
					s => s.Term(p => p.Global, "true")
				)
				.MinimumShouldMatch(1)
			);
		}