您的位置:首页 > 其它

MVC结合GROVE的应用 第二节 使用GROVE生成的Model

2011-01-18 13:37 411 查看
大家都知道GROVE是采用的实体映射原理,配合其生成表映射的是GROVE KIT工具,这一工具给我们编程提供了很大的方便,

虽然在MVC中不需要与表映射,但Models的书写也是少不了的,因此我们还是有必要使用可以生成的Model

如何能够被MVC使用,大家看一下我更改后的代码就清楚了:

修改前生成的实体类:

namespace CMS.Model
{
using System;
using Grove.ORM;
[DataTable("CMS_AdminT")]
public class CMS_AdminT
{
Int32 _id;
String _name;
String _trueName;
String _password;

[KeyField("id")]
public Int32 id
{
get{return this._id;}
set{this._id=value;}
}
[DataField("name")]
public String name
{
get{return this._name;}
set{this._name=value;}
}
[DataField("trueName")]
public String trueName
{
get{return this._trueName;}
set{this._trueName=value;}
}
[DataField("password")]
public String password
{
get{return this._password;}
set{this._password=value;}
}
}
}

修改后的实体类:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Grove.ORM;

namespace BxhlCMS.Models//注意命名空间
{
[DataTable("CMS_AdminT")]
public class AdminModels//注意此处类名
{
Int32 _id;
String _name;
String _trueName;
String _password;

[KeyField("id")]
public Int32 id
{
get { return this._id; }
set { this._id = value; }
}
[DataField("name")]
public String name
{
get { return this._name; }
set { this._name = value; }
}
[DataField("trueName")]
public String trueName
{
get { return this._trueName; }
set { this._trueName = value; }
}
[DataField("password")]
public String password
{
get { return this._password; }
set { this._password = value; }
}
}
}


把实体类修改好后放在Models中,就可以被MVC使用了。

上一节:MVC结合GROVE的应用 第一节 描述
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐