• Grove.net实践ORM学习笔记


    KeyLife富翁笔记
    作者: HongYuan
    标题: Grove.net实践ORM学习笔记
    关键字: 第一步
    分类: C#_Grove
    密级: 保护
    (评分: , 回复: 0, 阅读: 210) »»

    缺省安装Grove后,在项目中引用
    C:\Program Files\Pengya\GroveKit\Grove.dll

    打开项目配制文件 Web.config在</configuration>前增加
    <appSettings>
       <add key="DBConnString" value="Server=localhost;Uid=sa;Pwd=sa;Database=Press" />
       <add key="LogPath " value="c:\inetpub\wwwroot\WebApp1\LogFiles" />
    </appSettings>

    分别指定数据库连接参数,及日志文件路径


    2005-9-28 10:09:44   
     2005-9-28 10:16:18    创建实体映射类

    1.打开菜单[工具],选择[Grove Tools Kit];
    2.设置数据库连接参数(set database connection string),并打开连接(Connect Database);
    3.选择列表中的一个数据表,选择Preview Entity Class,即显示出当前数据表的实体映射类,并点击Create this file;

    其它说明:
    [DataTable("Sys_books")] 将自定义属性绑定到class或struct上,这里通过System.Data.DataTable类的构选方法与数据表绑定

    KeyField("BookID")]绑定主键
    [DataField("BookNo")]绑定字段

     
     2005-11-25 14:26:30    我的测试代码

    using System;
    using System.Collections;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Web;
    using System.Web.SessionState;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.HtmlControls;
    using Grove;
    using Grove.ORM;
    namespace WebApplication1
    {
     /// <summary>
     /// WebForm1 的摘要说明。
     /// </summary>
     public class WebForm1 : System.Web.UI.Page
     {
       protected System.Web.UI.WebControls.Button Button1;
     
       private void Page_Load(object sender, System.EventArgs e)
       {
         // 在此处放置用户代码以初始化页面
         
       }

       #region Web 窗体设计器生成的代码
       override protected void OnInit(EventArgs e)
       {
         //
         // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
         //
         InitializeComponent();
         base.OnInit(e);
       }
       
       /// <summary>
       /// 设计器支持所需的方法 - 不要使用代码编辑器修改
       /// 此方法的内容。
       /// </summary>
       private void InitializeComponent()
       {    
         this.Button1.Click += new System.EventHandler(this.Button1_Click);
         this.Load += new System.EventHandler(this.Page_Load);

       }
       #endregion

       private void Button1_Click(object sender, System.EventArgs e)
       {
         region r=new region();
         r.Code="wap";
         r.Name="wap";
         r.ParentID=-1;
                   
         ObjectOperator oo=new ObjectOperator(AppSettingManager.DBConnString);
         oo.BeginTranscation();
         try
         {
           oo.Insert(r);
           oo.Commit();
         }
         catch
         {
           oo.Rollback();
         }

       }
     }
    }

  • 相关阅读:
    POJ 3069 Saruman's Army
    POJ 3617 Best Cow Line
    Part5核心初始化_lesson2---设置svc模式
    Part5核心初始化_lesson1---异常向量表
    Part4_lesson4---Bootloader架构设计
    Part4_lesson3---U-Boot工作流程分析
    zigbee--绑定
    Part4_lesson2---ARM处理器这个硬件启动流程分析
    Part4_lesson1---Bootloader设计蓝图
    zigbee之MAC地址发送
  • 原文地址:https://www.cnblogs.com/ZhouXiHong/p/568096.html
Copyright © 2020-2023  润新知