Programming ASP.NET MVC-Fundamentals of ASP.NET MVC(七)Models

          我们在前面的博客中已经讨论了controller和View,接下来,我们来谈一下Models,Models通常被认为asp.net mvc构架里最重要的部分。因为它是包含程序所有逻辑的层,逻辑是所有的程序最难处理的部分。 

           如果只是从技术的观点来看的话,model只不过包含一系列类,在属性里公开数据,然后在方法里公开逻辑。model要么是“数据模型”或者“领域模型”,它的主要任务是管理数据。

           下面是EBuy要用到的一个Auction类。

public class Auction
{
    public long Id { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
    public decimal StartPrice { get; set; }
    public decimal CurrentPrice { get; set; }
    public DateTime StartTime { get; set; }
    public DateTime EndTime { get; set; }
}

          仅管,在接下来,我们可能还要在它上面添加其它的功能(比如说验证),但是它还是很有代表性的。 more kinds of classes (such as services and helpers) that all work together to make up the “Model” in “MVC.”。

发布了138 篇原创文章 · 获赞 11 · 访问量 40万+

猜你喜欢

转载自blog.csdn.net/yjjm1990/article/details/9013807
今日推荐