Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return DataSet From DataSet
Message
From
17/07/2010 15:43:06
 
 
To
17/07/2010 06:41:59
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
ASP.NET
Category:
LINQ
Miscellaneous
Thread ID:
01472665
Message ID:
01472809
Views:
49
Cetin, in this situation, LINQ is not necessary if one is performing a basic filter against a datatable. You can use the datatable Select method.

I don't have northwind on my current machine, but I just did this against adventureworks...I wanted to take a dataset of vendors, filter those with a credit rating of either 1 or 2, and place those vendors in a new datatable.
            string cstr = "Provider=SQLOLEDB;" +
                            @"server=.\SQL2008R2;trusted_connection=yes;database=AdventureWorks;";

            DataSet ds1 = new DataSet();
            OleDbDataAdapter da = new OleDbDataAdapter("select * from Purchasing.Vendor", cstr);
            da.Fill(ds1, "Vendors");

            DataTable dtCreditRating1_2 = ds1.Tables[0].Select("CreditRating = 1 or CreditRating = 2").CopyToDataTable();
Both work, but IMO LINQ to DataSets is a bit of overkill (at least for untyped datasets....LINQ to DataSets is a bit cleaner when using typed datasets)

For multiple tables where the criteria needs to join data together, it's more a toss-up, since you'd need to create an ADO.NET relation....and if you're going to do that, you may as well just use LINQ. But again, LINQ to Datasets is much cleaner when using typed datasets.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform