Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return DataSet From DataSet
Message
De
16/07/2010 16:45:21
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
16/07/2010 07:40:44
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Divers
Thread ID:
01472665
Message ID:
01472751
Vues:
46
>>>How do you return a dataset, using Linq, of rows from another dataset?
>>
>>Here is a sample:
>>
>>    DataTable tbl = new DataTable();
>>	using (OleDbConnection con = new OleDbConnection(
>>	"Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;"+
>>	@"Data Source=C:\Program Files\Microsoft SQL Server Compact Edition\v3.5\Samples\northwind.sdf;"))
>>	{
>>	  con.Open();
>>	  OleDbCommand cmd = con.CreateCommand();
>>	  cmd.CommandText = "select * from customers";
>>	  OleDbDataReader rdr = cmd.ExecuteReader();
>>	  tbl.Load(rdr);
>>	  con.Close();
>>	}
>>	
>>	DataTable usaCustomers =
>>	 tbl.AsEnumerable()
>>	    .Where(c => c.Field<string>("Country") == "USA")
>>		.CopyToDataTable();
>>	
>>	DataTable ukCustomers =
>>	 tbl.AsEnumerable()
>>	    .Where(c => c.Field<string>("Country") == "UK")
>>		.CopyToDataTable();
>>	
>>//	usaCustomers.Dump("USA");
>>//	ukCustomers.Dump("UK");
>>
Cetin
>
>Not so easy with a *DataSet* though :-}

Sorry I don't understand what you mean Viv. What is hard in that sample? (I wouldn't use a dataset when there is Linq but still I don't think it is very hard).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform