static void testDistinct()
{ DataTable t = new DataTable();
t.Columns.Add("Category", typeof(string)); t.Columns.Add("Product", typeof(string)); t.Columns.Add("Version", typeof(string)); t.Rows.Add("OS", "Windows", "2003"); t.Rows.Add("OS", "Windows", "Vista"); t.Rows.Add("Application", "Office", "XP"); t.Rows.Add("Application", "Office", "2003"); t.Rows.Add("Application", "Project", "2003"); t.Rows.Add("Database", "SQL", "2000"); t.Rows.Add("Database", "SQL", "2005"); t.Rows.Add("Database", "SQL", "2000"); //Duplicated Console.WriteLine("Original Rows Count = " + t.Rows.Count.ToString());
Console.WriteLine("DISTINCT Category Rows Count = " + t.DefaultView .ToTable(true, "Category").Rows.Count.ToString());
Console.WriteLine("DISTINCT Category, Product Rows Count = " + t.DefaultView .ToTable(true, "Category", "Product").Rows.Count.ToString());
Console.WriteLine("DISTINCT Category, Product, Version Rows Count = " + t.DefaultView .ToTable(true, "Category", "Product", "Version").Rows.Count.ToString());
}