Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return DataSet From DataSet
Message
De
17/07/2010 15:43:06
 
 
À
17/07/2010 06:41:59
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Divers
Thread ID:
01472665
Message ID:
01472809
Vues:
50
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform