コード例 #1
0
        public async Task <IActionResult> ApplyQueryFilter(string modelId, string queryId)
        {
            await _eqManager.ReadRequestContentFromStreamAsync(modelId, Request.Body);

            var orders = _dbContext.Orders
                         .Include(o => o.Customer)
                         .Include(o => o.Employee)
                         .AsQueryable();

            var text = (string)_eqManager.ClientData["text"];

            //read full-text search text
            if (!string.IsNullOrEmpty(text))
            {
                var options = new FullTextSearchOptions
                {
                    Depth = 2,

                    // filter to use search for string fields we chose
                    Filter = (propInfo) =>
                    {
                        if (propInfo.DeclaringType == typeof(Order))
                        {
                            return(propInfo.PropertyType == typeof(Customer) || propInfo.PropertyType == typeof(Employee));
                        }

                        if (propInfo.PropertyType == typeof(string))
                        {
                            if (propInfo.DeclaringType == typeof(Customer))
                            {
                                return(propInfo.Name == "ContactName" || propInfo.Name == "Country");
                            }

                            if (propInfo.DeclaringType == typeof(Employee))
                            {
                                return(propInfo.Name == "FirstName" || propInfo.Name == "LastName");
                            }
                        }

                        return(false);
                    }
                };

                orders = orders.FullTextSearchQuery <Order>(text, options);
            }


            orders = orders
                     .DynamicQuery <Order>(_eqManager.Query);

            var list = orders.ToPagedList(_eqManager.Paging.PageIndex, 15);

            ViewData["Text"] = text;

            return(View("_OrderListPartial", list));
        }
コード例 #2
0
        public async Task <ActionResult> ApplyQueryFilter(string modelId)
        {
            Request.InputStream.Position = 0;
            await _eqManager.ReadRequestContentFromStreamAsync(modelId, Request.InputStream);

            var orders = _dbContext.Orders
                         .Include(o => o.Customer)
                         .Include(o => o.Employee)
                         .AsQueryable();

            var clientData = (IDictionary <string, object>)_eqManager.ClientData;
            var text       = clientData != null && clientData.TryGetValue("text", out object value)
                ? (string)value : "";

            //read full-text search text
            if (!string.IsNullOrEmpty(text))
            {
                var options = new FullTextSearchOptions
                {
                    Depth = 2,

                    // filter to use search for string fields we chose
                    Filter = (propInfo) =>
                    {
                        if (propInfo.DeclaringType == typeof(Order))
                        {
                            return(propInfo.PropertyType == typeof(Customer) || propInfo.PropertyType == typeof(Employee));
                        }
                        else if (propInfo.PropertyType == typeof(string))
                        {
                            if (propInfo.DeclaringType == typeof(Customer))
                            {
                                return(propInfo.Name == "CompanyName" || propInfo.Name == "Country");
                            }
                            else if (propInfo.DeclaringType == typeof(Employee))
                            {
                                return(propInfo.Name == "FirstName" || propInfo.Name == "LastName");
                            }
                        }
                        return(false);
                    }
                };

                orders = orders.FullTextSearchQuery <Order>(text, options);
            }


            orders = orders
                     .DynamicQuery <Order>(_eqManager.Query);

            var list = orders.ToPagedList(_eqManager.Chunk.Page, 15);

            ViewData["Text"] = text;

            return(View("_OrderListPartial", list));
        }
コード例 #3
0
ファイル: FullTextSearch.cs プロジェクト: brhinescot/Loom
            public ConditionParser(string condition, FullTextSearchOptions options)
            {
                ConditionStream stream = new ConditionStream(condition, options);

                this.options = options;

                RootExpression    = new ConditionExpression(options);
                currentExpression = RootExpression;

                Reset();

                while (stream.Read())
                {
                    if (ConditionOperator.IsSymbol(stream.Current))
                    {
                        PutToken();
                        SetToken(stream.Current);
                        PutToken();
                        continue;
                    }
                    switch (stream.Current)
                    {
                    case ' ':
                        PutToken();
                        continue;

                    case '(':
                        PushExpression();
                        continue;

                    case ')':
                        PopExpression();
                        continue;

                    case '"':
                        PutToken();
                        inQuotes = true;
                        SetToken(stream.ReadQuote());
                        PutToken();
                        inQuotes = false;
                        continue;
                    }
                    AddToken(stream.Current);
                }
                PutToken();

                if (!ReferenceEquals(RootExpression, currentExpression))
                {
                    if ((options & FullTextSearchOptions.ThrowOnUnbalancedParens) != 0)
                    {
                        throw new InvalidOperationException("Unbalanced parentheses.");
                    }
                }
            }
コード例 #4
0
    public static string cleanSearchString(string stringIn, bool inflectional = true)
    {
        if (stringIn.Length == 0)
        {
            return("");
        }

        //Determine whether to perform an inflectional search - i.e. FORMSOF(INFLECTIONAL, "search term")
        FullTextSearchOptions myFTSOptions = default(FullTextSearchOptions);

        if (inflectional)
        {
            myFTSOptions = FullTextSearchOptions.Default;
        }
        else
        {
            myFTSOptions = FullTextSearchOptions.None;
        }

        ParseFullText.FullTextSearch myFTS = new ParseFullText.FullTextSearch(stringIn, myFTSOptions);
        return(myFTS.NormalForm);
    }
コード例 #5
0
        public FullTextSearch(string condition, FullTextSearchOptions options)
        {
            this.condition = condition;
            this.options   = options;

            ConditionParser parser = new ConditionParser(condition, options);

            normalForm = parser.RootExpression.ToString();

            searchTerms = new List <string>();

            foreach (ConditionExpression exp in parser.RootExpression)
            {
                if (exp.IsSubexpression)
                {
                    continue;
                }
                if (exp.Term.Length == 0)
                {
                    continue;
                }
                searchTerms.Add(exp.Term);
            }
        }
コード例 #6
0
 public ConditionExpression(FullTextSearchOptions options) : this()
 {
     this.options = options;
 }
コード例 #7
0
 public ConditionStream(string condition, FullTextSearchOptions options)
 {
     this.options   = options;
     this.condition = Regex.Replace((condition ?? String.Empty), @"\x09|\x0D|\x0A|[\x01-\x08]|\x10|[\x0B-\x0C]|[\x0E-\x1F]", " ");
     index          = -1;
 }
コード例 #8
0
        public static string Parse(string condition, FullTextSearchOptions options)
        {
            var parser = new ConditionParser(condition, options);

            return(parser.RootExpression.ToString());
        }