public override Collection MakeCollection(CollectionRequestContext context) { var collection = new Collection(); using (SqlConnection connection = new SqlConnection(@"Data Source=.\SQLEXPRESS;Initial Catalog=SalesDB;Integrated Security=True;MultipleActiveResultSets=True")) { using (SqlCommand command = new SqlCommand("select p.Name Product, r.Name Region, f.Price Price, o.Date Date from Facts f join Orders o on f.OrderId=o.OrderId join Products p on f.ProductId=p.ProductId join Regions r on f.RegionId=r.RegionId", connection)) { connection.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { string product = reader.GetString(0); string region = reader.GetString(1); Decimal price = reader.GetDecimal(2); DateTime date = reader.GetDateTime(3); string imagePath = String.Format("http://localhost:1297/ClientBin/Images/{0}.jpg", product); ItemImage image = new ItemImage(new Uri(imagePath, UriKind.Absolute)); collection.AddItem("", null, "", image, new Facet[] { new Facet("Регион", region), new Facet("Продукт", product), new Facet("Цена", (double)price), new Facet("Дата", date) }); } } } collection.Name = "Sales Collection"; return collection; }
// Override this method to provide a Collection object for the request. public abstract Collection MakeCollection(CollectionRequestContext context);