Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> ApplyQueryFilter(string modelId, string queryId)
        {
            await _eqManager.ReadRequestContentFromStreamAsync(modelId, Request.Body);

            var queryable = _dbContext.Orders
                            .Include(o => o.Customer)
                            .Include(o => o.Employee)
                            .DynamicQuery <Order>(_eqManager.Query);

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

            return(View("_OrderListPartial", list));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> ApplyQueryFilter(string modelId, string queryId)
        {
            Request.InputStream.Position = 0;

            await _eqManager.ReadRequestContentFromStreamAsync(modelId, Request.InputStream);

            var query = _eqManager.Query;

            var queryable = _dbContext.Orders
                            .Include(o => o.Customer)
                            .Include(o => o.Employee)
                            .OrderBy(o => o.Id)
                            .DynamicQuery <Order>(query);

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

            return(View("_OrderListPartial", list));
        }