views:

79

answers:

3

Assume I have a large dataset and I want to run a "like" function in the dataset eg column - Name

Is there any way to run a like statement in a dataset.

Is it possible with ASP.NET?

I dont want to run a query to the database.

Thanks

A: 

You, my friend, are in need of some LINQ. It is a generic query language which can, through the use of various providers, query SQL based data stores as well as in memory objects like lists. http://msdn.microsoft.com/en-us/netframework/aa904594.aspx

stimms
+5  A: 
dataTable.Select("Name like '%rob%'");

The LIKE statement is supported in the DataTable.Select function as documented here:

http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression.aspx

David Stratton
Sorry for the old link to the 1.1 version of the framework but it's supported in all later versions as well.
David Stratton
I think you need to use * instead of %
astander
@astander: the docs say they can be used interchangably
Joel Coehoorn
The "special" rule for the expressions is that they can't be used in the middle of a string, so 'te*xt' is not allowed in this format, but it would be in a normal sql query.
Joel Coehoorn
Yes, ok i see that. Correct.
astander
A: 

Can you not use

YourDataTable.Select("Name LIKE 'surname*'");
astander