【发布时间】:2012-07-10 17:12:08
【问题描述】:
我在我的项目中看到了这一点
class Product
{
public string Name { get; private set; }
public decimal Price { get; private set; }
public Product(string name, decimal price)
{
Name = name;
Price = price;
}
Product() {}
public static List<Product> GetSampleProducts()
{
return new List<Product>
{
new Product { Name="West Side Story", Price = 9.99m },
new Product { Name="Assassins", Price=14.99m },
new Product { Name="Frogs", Price=13.99m },
new Product { Name="Sweeney Todd", Price=10.99m}
};
}
public override string ToString()
{
return string.Format("{0}: {1}", Name, Price);
}
}
【问题讨论】:
-
我认为你需要提供更多关于context的信息,尤其是关于你看过哪些项目。
标签: asp.net-mvc-3 c#-4.0 entity-framework-4 c#-3.0