PaginatedSearchAndFilter icon indicating copy to clipboard operation
PaginatedSearchAndFilter copied to clipboard

Generic expando object to handle search from front end MVC view

Open fasteddys opened this issue 2 years ago • 7 comments

Hello, this is very nice after playing around I was hoping to get a sample with asp Core View, on how the developers can implement with a generic expando/dynamic object

  • [ ] For e.g. if user are searching songs or images or some media, how can we get handle it as a generic request.
  • [ ] Also what do we need to configure in the pipeline request handler so it handle it.

fasteddys avatar Jul 04 '23 07:07 fasteddys

For e.g. I am including sample code to get dynamic lists etc. like so, this approach/option would significantly reduce code

private static void PrintSearchedDynamicList(IEnumerable<dynamic> dynamicList)
        {
            List<string> list = new List<string>();

            if (dynamicList.Count() < 1)
            {
                Console.WriteLine("We couldn't find any matching records.");
            }
            else
            {
                foreach (var dynamicObject in dynamicList)
                {
                    foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(dynamicObject))
                    {
                        string name = descriptor.Name;
                        object value = descriptor.GetValue(dynamicObject);

                    // add some logic to search with this dll, or call the paginatedsearch but how to configure and map

                        if (list.Contains(name + value) is false)
                        {
                            list.Add(name + value);
                            Console.WriteLine("{0}: {1}", name, value);
                        }
                    }
                }
            }
        }

fasteddys avatar Jul 04 '23 07:07 fasteddys

  • [ ] For e.g. if user are searching songs or images or some media, how can we get handle it as a generic request.

Unfortunately, I did not get what you mean.

[ ] Also what do we need to configure in the pipeline request handler so it handle it.

Currently we have no plans for pipelines, but I'd love to hear your idea.

baranacikgoz avatar Jul 04 '23 19:07 baranacikgoz

Sorry not pipelines, at least based on what i know.

Use case for typical developers: Often we have to create a search and filter page in web aps. It would be sooo helpful, if we could reflect/extract the models attributes and create a search/filter page for the exposed attributes.

We would like to explore/see if there is a json object or C# .net object, that you can expose (which can take any poco model/entity) and spit out the list of search and filter items.

Using that exposed object, we can use that to iterate a list all the search items, and filter items on a page. And we can bind to that.

Check out this page demo.. https://querybuilder.js.org/ where they create the expression for the search, but it would the inverse, where the developer creates the expression and binds it to your search dll.

fasteddys avatar Jul 08 '23 13:07 fasteddys

Do you mean such a thing like that?

public class User
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public DateTime DateOfBirth { get; set; }
}

// Generate a list of searchable fields
var searchableFields = SearchableFieldGenerator.Generate<User>();

// searchableFields might contain "FirstName", "LastName", "DateOfBirth"

baranacikgoz avatar Jul 10 '23 18:07 baranacikgoz

yes @baranacikgoz it would be even easier if we could annotate the attributes.

fasteddys avatar Dec 15 '23 22:12 fasteddys

hello @baranacikgoz sorry about the confusion, hope you can visualize, I am posting some examples.

Usually theres a poco or viewmodel.. I have to attach search and pagination based on the results on the front end page

Some examples to help visualize,


drex_searchandfilter_screen


Capture-233


uuid-750749cf-7051-2e99-412f-4663ca12b41e

fasteddys avatar Apr 03 '24 17:04 fasteddys

hello

fasteddys avatar Apr 29 '24 15:04 fasteddys