惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
博客园 - 三生石上(FineUI控件)
量子位
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Apple Machine Learning Research
Apple Machine Learning Research
爱范儿
爱范儿
V
Visual Studio Blog
雷峰网
雷峰网
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
Blog — PlanetScale
Blog — PlanetScale
有赞技术团队
有赞技术团队
博客园 - 叶小钗
Microsoft Azure Blog
Microsoft Azure Blog
T
The Blog of Author Tim Ferriss
U
Unit 42
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
小众软件
小众软件
阮一峰的网络日志
阮一峰的网络日志
Y
Y Combinator Blog

博客园 - qqhe325

一个js游戏 向del.icio.us学习 lucene.net优化总结 Fxcop使用笔记 web service 记录1 自定义加密web.config实验记录 DTC:该伙伴事务管理器已经禁止了他对远程/网络事务的支持 C#基础- 抽象类,静态类 js自动加载日期类 img的onload事件 当图片路径超出网站根目录时 vs2005宏的问题 asp.net 2.0 access 未指定的错误 oledbparameter在update时出错不报错 delegate和event例子 你试图打开的项目是Web项目,请指定URL路径 asp.net 在分析向此请求提供服务所需资源时出错 策略模式 我们是怎样的一代人[转]
grove 小例子
qqhe325 · 2007-07-20 · via 博客园 - qqhe325

using System;
using Grove.ORM;
using System.Collections;namespace ConsoleApplication1
{
//自动生成
    [DataTable("dnt_words")]
    
public class dnt_words
    {
        Int32 _id;
        String _admin;
        String _find;
        String _replacement;
//    [DataField("id")]
    
//    [KeyField("id",KeyType = UniqueIDType.OtherDefinition)]  //  w        
    
//      [KeyField("id",KeyType = UniqueIDType.AutoIdentitiy)]    //  r
          [KeyField("id")]        //r
        public Int32 id
        {
            
get{return this._id;}
            
set{this._id=value;}
        }
        [DataField(
"admin")]
        
public String admin
        {
            
get{return this._admin;}
            
set{this._admin=value;}
        }
        [DataField(
"find")]
        
public String find
        {
            
get{return this._find;}
            
set{this._find=value;}
        }
        [DataField(
"replacement")]
        
public String replacement
        {
            
get{return this._replacement;}
            
set{this._replacement=value;}
        }
    }
//不是自动生成,但可以做成code_smith模板
    public class dnt_words_Collection : System.Collections.CollectionBase
    {
        
public dnt_words this[Int32 index]
        {
            
set
            {
                
this.List[index] = value;
            }
            
get
            {
                
return (dnt_words)this.List[index];
            }
        }
public Int32 Add(dnt_words value)
        {
            
return this.List.Add(value);
        }
    }
}

using System;
using Grove.ORM;
using System.Collections;
using Grove.Sql;
using Grove.Util;namespace ConsoleApplication1
{
/// <summary>
    
/// dnt_wordsDB 的摘要说明。
    
/// </summary>
    public class dnt_wordsDB
    {
        
public static void Main()
        {
            dnt_words dw
=new dnt_words();
        
//    dw.admin="a4647";
         
//   dw.find="aaa";
        
//dw.replacement="ccc";
            dw.id=2;
            
//dnt_wordsDB.Insert(dw);
            
//dnt_wordsDB.Update(dw);
        
//    dnt_wordsDB.Remove(dw);
    
//    dnt_words_Collection dwc=    dnt_wordsDB.Read_dnt_words();
        
//    Console.WriteLine(dwc.Count);
            Console.WriteLine(Get_dnt_words_Count());
        }
public static Int32 Get_dnt_words_Count()
        {
           IDbOperator dbOperator
=DbOperatorFactory.GetDbOperator(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\web\dnt_acc_n1_1_src_access\Source Code\database\access_db.mdb;Persist Security Info=False");
            
try
            {
                
return Convert.ToInt32(dbOperator.ExecScalar("select count(*) from dnt_words"));            
            }
            
finally
            {
                dbOperator.Dispose();
            }
        }
public static dnt_words_Collection  Read_dnt_words()

        {
            
            ObjectOperator a

=new ObjectOperator(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\web\dnt_acc_n1_1_src_access\Source Code\database\access_db.mdb;Persist Security Info=False");
            dnt_words_Collection dwc
=new dnt_words_Collection();
            
try
            {
            ArrayList orders
=a.GetObjectSet(new ObjectQuery(typeof(dnt_words),"dnt_words.find='aaa'"));
                
foreach(object c in     orders)
                {
                    dnt_words d
=(dnt_words)c;
                    dwc.Add(d);
                }
            }
            
catch(Exception e)
            {
               Console.WriteLine(e.Message);
             Console.WriteLine(e.StackTrace);
            }
finally
            {
                a.Dispose();
            }
            
return dwc;

        }

public static void Remove(dnt_words dw)

        {

            ObjectOperator a

=new ObjectOperator(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\web\dnt_acc_n1_1_src_access\Source Code\database\access_db.mdb;Persist Security Info=False");
                a.BeginTranscation();
            
try
            {
a.Remove(dw);
                a.Commit();
            }
            
catch
            {
a.Rollback();
                
throw;
            }
finally
            {
                a.Dispose();

            }              

        }

public static void Insert(dnt_words dw)
            {
ObjectOperator a
=new ObjectOperator(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\web\dnt_acc_n1_1_src_access\Source Code\database\access_db.mdb;Persist Security Info=False");
                    a.BeginTranscation();
                
try
                {
a.Insert(dw);
a.Commit();
                    Console.WriteLine(
"succeed");

                }

catch
                {
a.Rollback();
                    Console.WriteLine(
"error");
                    
throw;
                }
                
finally
                {
                    a.Dispose();
                    Console.WriteLine(
"end");
                }      

            }

public static void Update(dnt_words dw)
        {
            ObjectOperator a
=new ObjectOperator(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\web\dnt_acc_n1_1_src_access\Source Code\database\access_db.mdb;Persist Security Info=False");
                a.BeginTranscation();
            
try
            {
                a.Update(dw);
                a.Commit();
            }
            
catch
            {
a.Rollback();
                
throw;
            }
            
finally
            {
a.Dispose();
            }

        }

    }
}