CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  C#

Gentle.NET这样用错在那里?

楼主baryjim(吃饭-睡觉-打豆豆)2005-08-02 10:39:36 在 .NET技术 / C# 提问

using   System;  
  using   Gentle.Common;  
  using   Gentle.Framework;  
  using   Gentle.Provider.SQLServer;  
  using   log4net;  
  using   QuickGraph;  
   
   
  namespace   GentleExample1  
  {  
  [TableName("Users")]  
  public   class   User   :   Persistent  
  {  
  private   int   userId;  
  private   string   userName;  
   
  //   this   is   used   by   clients   to   construct   new   users  
  public   User(   string   userName   )   :   this(   0,   userName   )   {}  
   
  //   this   is   used   by   Gentle   to   reconstruct   objects   read   from   the   database  
  public   User(   int   userId,   string   userName   )  
  {  
  this.userId   =   userId;  
  this.userName   =   userName;  
  }  
   
  //   this   is   used   by   client   to   fetch   users   from   the   database  
  static   public   User   Retrieve(   int   userId   )  
  {  
  Key   key   =   new   Key(   typeof(User),   true,   "Id",   userId   );  
  return   Broker.RetrieveInstance(   typeof(User),   key   )   as   User;  
  }  
   
  [TableColumn("UserId"),   PrimaryKey(AutoGenerated=true)]  
  public   int   Id  
  {  
  get{   return   userId;   }  
  set{   userId   =   value;   }  
  }  
   
  [TableColumn(NotNull=true)]  
  public   string   Name  
  {  
  get{   return   userName;   }  
  set{   userName   =   value;   }  
  }  
  }  
  }  
  =====================  
  using   System;  
  using   Gentle.Common;  
  using   Gentle.Framework;  
  using   Gentle.Provider.SQLServer;  
  using   log4net;  
  using   QuickGraph;  
   
  namespace   GentleExample1  
  {  
  class   Class1  
  {  
  [STAThread]  
  static   void   Main(string[]   args)  
  {  
  User   ford   =   new   User(   10,"Ford   Prefect"   );  
   
  ford.Persist();   //   save   the   new   user   and   assign   an   id   value  
   
  User   prefect   =   User.Retrieve(   ford.Id   );   //   retrieve   the   existing   user  
  }  
  }  
  }  
  为什么显示ford.Persist();   出现了异常,  
  未处理的“System.ArgumentNullException”类型的异常出现在   mscorlib.dll   中。  
   
  其他信息:   键不能为空。  
   
  是不是我没有配置文件啊,配置文件怎么设置,文档太少了,真是的,还开源哪! 问题点数:20、回复次数:7Top

1 楼baryjim(吃饭-睡觉-打豆豆)回复于 2005-08-03 06:40:45 得分 0

upTop

2 楼net_lover(【孟子E章】)回复于 2005-08-03 07:44:30 得分 20

问题都说的很明确了:  
  键不能为空。  
   
  你插入数据库的时候缺少字段,或者没有把数据库字段的id字段设置为字段加1的类型  
  Top

3 楼baryjim(吃饭-睡觉-打豆豆)回复于 2005-08-04 06:53:46 得分 0

谁能给我一个最简单的例子Top

4 楼baryjim(吃饭-睡觉-打豆豆)回复于 2005-08-04 16:17:36 得分 0

upTop

5 楼baryjim(吃饭-睡觉-打豆豆)回复于 2005-08-05 08:13:24 得分 0

谁能帮我改正过来,拜托了,实在找不到可用的文档。Top

6 楼bary()回复于 2005-08-05 13:25:14 得分 0

upTop

7 楼baryjim(吃饭-睡觉-打豆豆)回复于 2005-08-11 19:19:20 得分 0

救命啊!!!Top

相关问题

  • net use使用错误?
  • 我到底是那里调用错了
  • 初学搾练!不知道那里用错了!大家帮忙指教!
  • NoAbsoluteExpiration用错了?
  • ado.net引用错误
  • dll引用错误???????????????
  • asp中调用错误!
  • 怎么用错务处理?
  • [help]mysqldump应用错误!
  • asp.net使用错误求教

关键词

  • 字段
  • gentle
  • userid
  • ford
  • username
  • persist
  • retrieve
  • key
  • user
  • true

得分解答快速导航

  • 帖主:baryjim
  • net_lover

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo