views:

119

answers:

4

I was wondering if we retrieve a dataset in C# from SQL database .then can we query on it

+2  A: 

Not sure if this is what you're looking for buy, you can query on the datatables in the dataset using Select() and you get an array of DataRows

dataSet.Tables["myTable"].Select("Id=55")

http://msdn.microsoft.com/en-us/library/way3dy9w.aspx

Jaime
A: 

You can use DataView.RowFilter property, which provides a fairly simplistic query language, or you can use LINQ to DataSet in .NET 3.5+.

Pavel Minaev
A: 

Not out of the box, but check out QueryADataSet. You can also use Compute and Select on a DataTable.

JP Alioto
+2  A: 

You can do that easily with LINQ if you are using .NET 3.5 or greater.

Before doing so I would make sure that you are doing everything you can related to selecting your datasets on the database side.

Ask yourself if you really need to do this in your application, or if it can live on the database side (as a view, a stored procedure, etc.).

By keeping your query logic on the database side, you keep it where it belongs and will be executed most efficiently.

Also, by letting the database do all of your query work you allow your application(s) to be more scaleable because the database will almost always be easier and more efficient to parallelize and scale than your application itself.

jscharf
Quite helpful man. Well i have never worked on LINQ so would you provide a helpful link that is more descriptive on coding point of view rather than theory because i am really bad at theory :S
Mobin
Start here: http://msdn.microsoft.com/en-ca/library/bb397926.aspx
Pavel Minaev