I’m running > 50K simple selects on a table in sql server and I’d really like to speed it up. I’ve read that you can pull the data into memory and use something like a dataview to query against.
Is there a way to use something in Linq to end up with –
var dv = CreateTheDataViewFromDatabase();
var result = dv.Where("CategoryId=2 And Uncle='bob'");
And would this be a lot faster than querying the database so many times? I’m concerned there’s no index on the dataview so the gains of having it in memory might be lost.
Yes, you can use Linq against your
DataTableby usingAsEnumerable. For example:Make sure you add a reference to
System.Data.DataSetExtensionsUpdate: Dynamic SQL
It is possible to build your conditions on the fly. Have a look at Dynamic LINQ and Predicate Builder