Exemple #1
0
        public void Value_Table_Row_Count_Should_Equal_Search_Term_Count()
        {
            var iter  = new Random().Next(1, 10);
            var terms = RandomStrings(iter);

            var search = SearchTermTable.From(terms);

            Assert.Equal(iter, search.Rows.Count);
        }
Exemple #2
0
        /// <summary>
        /// Search the concept tree for records matching the provided terms, and stopping at the <paramref name="rootId"/>
        /// </summary>
        /// <returns>Collection of concepts that match the search terms</returns>
        /// <param name="rootId">Root parent identifier.</param>
        /// <param name="terms">Search terms.</param>
        public async Task <IEnumerable <ConceptHint> > SearchAsync(Guid?rootId, params string[] terms)
        {
            using (var cn = new SqlConnection(opts.ConnectionString))
            {
                await cn.OpenAsync();

                var records = await cn.QueryAsync <ConceptHintRecord>(
                    Sql.Query,
                    new
                {
                    terms = SearchTermTable.From(terms),
                    rootId,
                    user   = user.UUID,
                    groups = GroupMembership.From(user),
                    admin  = user.IsAdmin
                },
                    commandTimeout : opts.DefaultTimeout,
                    commandType : CommandType.StoredProcedure
                    );

                return(records.Select(r => r.ConceptHint()));
            }
        }
Exemple #3
0
        public async Task <IEnumerable <Concept> > GetWithParentsBySearchTermAsync(Guid?rootId, string[] terms)
        {
            using (var cn = new SqlConnection(opts.ConnectionString))
            {
                await cn.OpenAsync();

                var grid = await cn.QueryMultipleAsync(
                    queryParentsBySearchTerm,
                    new
                {
                    terms = SearchTermTable.From(terms),
                    rootId,
                    user   = user.UUID,
                    groups = GroupMembership.From(user),
                    admin  = user.IsAdmin
                },
                    commandTimeout : opts.DefaultTimeout,
                    commandType : CommandType.StoredProcedure
                    );

                return(HydratedConceptReader.Read(grid));
            }
        }