426 Views
Select objects in C# with real SQL syntax. Give your users the ability to filter/select data during runtime.
Join in on a hand-picked round up of the best .NET articles every day.
Curated by our Moderators and Voted up by our Community. Free.
Select objects in C# with real SQL syntax. Give your users the ability to filter/select data during runtime.
The collection is already in memory. It doesn't matter how do you run a query over it. Even if you run a lazy LINQ query on a collection - the collection is already there, the query itself is executed in a lazy way.
However, creating a DataTable and loading the data into it is an expensive operation. If you already have a way to parse user-defined expressions - I wouldn't recommend using the DataTable approach. I don't know of any way to parse such expression so I use DataTables in my projects (assuming the data is small).
You can take a look at my CLAP project: http://adrianaisemberg.github.com/CLAP/.
I use such a mechanism to parse user-defined validation expressions (here: http://adrianaisemberg.github.com/CLAP/#validation_expression).
The post is about a clever use of an old existing feature. It doesn't talk about the performance of it neither recommends it over LINQ.