MVC结合GROVE的应用 第二节 使用GROVE生成的Model
2011-01-18 13:37
411 查看
大家都知道GROVE是采用的实体映射原理,配合其生成表映射的是GROVE KIT工具,这一工具给我们编程提供了很大的方便,
虽然在MVC中不需要与表映射,但Models的书写也是少不了的,因此我们还是有必要使用可以生成的Model
如何能够被MVC使用,大家看一下我更改后的代码就清楚了:
修改前生成的实体类:
修改后的实体类:
把实体类修改好后放在Models中,就可以被MVC使用了。
上一节:MVC结合GROVE的应用 第一节 描述
虽然在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的应用 第一节 描述
相关文章推荐
- jqGrid与Struts2的结合应用(六) —— 使用colModel设置查询功能
- jqGrid与Struts2的结合应用(六) —— 使用colModel设置查询功能
- jqGrid与Struts2的结合应用(六) —— 使用colModel设置查询功能
- 使用dynamic在ASP.NET MVC中应用匿名ViewModel
- jqGrid与Struts2的结合应用(六) ------ 使用colModel设置查询功能 .
- Mybatis中使用mybatis-generator结合Ant脚本快速自动生成Model、Mapper等文件 推荐
- jqGrid与Struts2的结合应用(六) —— 使用colModel设置查询功能
- jqGrid与Struts2的结合应用(六) —— 使用colModel设置查询功能
- 使用Mybatis Generator结合Ant脚本快速自动生成Model、Mapper等文件的方法
- jqGrid与Struts2的结合应用(六) —— 使用colModel设置查询功能
- jqGrid与Struts2的结合应用(六) —— 使用colModel设置查询功能
- MVC结合GROVE的应用 第一节 描述
- Mybatis中使用mybatis-generator结合Ant脚本快速自动生成Model、Mapper等文件
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)
- ASP.NET MVC 4.0 中使用NPOI 2.2.0 按模板生成Excel报表
- MVC到底使用哪种方式传递Model,在ViewData、ViewBag、PartialView、TempData、ViewModel、Tuple之间取舍
- jqgrid编辑行时上传图片,使用webuploader结合c# mvc的方式
- ASP.NET窗体和ASP.NET MVC在同一应用中混合使用
- jquery 中$.post获取MVC Controller中JsonResult返回包含LIst<Model>类型的子List<Model>的高级使用方法
- webservice使用EF生成的model序列化问题