public override CategorySale[] GetSalesByFilmCategory(string category)
{
List<CategorySale> itemlist = new List<CategorySale>();
using (SakilaEntities dc = new SakilaEntities())
{
var model = from c in dc.sales_by_film_category
where c.category.Contains(category)
orderby c.category
select c;
List<sales_by_film_category> sales = model.ToList();
for (int i = 0; i < sales.Count; i++)
{
CategorySale cs = new CategorySale();
if (sales[i].total_sales.HasValue)
{
cs = cs.Create(sales[i].category, sales[i].total_sales.Value);
}
else
{
cs = cs.Create(sales[i].category);
}
itemlist.Add(cs);
}
}
return itemlist.ToArray<CategorySale>();
}