Suggestions for implementing a simple search for “business objects” in a .NET WinForms app?

前端 未结 4 425
失恋的感觉
失恋的感觉 2021-01-16 03:01

What\'s the best way to go about providing a simple search capability for \"business objects\" in a .NET WinForms application?

By \"simple search\" I mean something

4条回答
  •  迷失自我
    2021-01-16 04:01

    As long as you don't have too many objects it would make sense to do what you're describing, just by looping through each object. You could go with a regular expression instead of just Contains to give it a little more flexibility. Contains is going to give you a match on an object instead of just a string value of a property inside your object. Matching the string would probably be more useful to you.

    One thing you could do is make a method in your objects that is simply a concatenated string of all of the strings in that object you would want to search. Then apply the regular expression to search the value that results from that method. It's easily not going to be the greatest performing solution, but it would be quick and easy. Like I said, as long as you don't have too many objects it will be fine.

提交回复
热议问题