您的位置:首页 > 编程语言 > ASP

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

2013-06-03 15:29 344 查看
我们在前面的博客中已经讨论了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.”。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐