[已解决问题] 最新版本的Ibatis.net DataMapper出错
提问时间: 2007-11-12 21:07
悬赏分:10 浏览:415 次

DataMapper1.2创建Mapper实例没有错,可1.6出错,老是报Null值,在网上没搜到最新版本的,哪位可以做一个最新版本的小例子?谢谢


提问者:王德水 - 初学一级

问题补充:那个我看过了,我只想用DataMapper, NpetShop里用了DataAccess
using IBatisNet.Common.Utilities;
using IBatisNet.DataMapper;
using IBatisNet.DataMapper.Configuration;

/// <summary>
/// Mapper 的摘要说明。
/// </summary>
namespace LiveBookings
{
public class Mapper
{
private static volatile SqlMapper _mapper = null;

protected static void Configure(object obj)
{
_mapper = (SqlMapper)obj;
}
protected static void InitMapper()
{
ConfigureHandler handler = new ConfigureHandler(Configure);
_mapper = SqlMapper.ConfigureAndWatch(handler);
}

public static SqlMapper Instance()
{
if (_mapper == null)
{
lock (typeof(SqlMapper))
{
if (_mapper == null) // double-check
InitMapper();
}
}
return _mapper;
}

public static SqlMapper Get()
{
return Instance();
}
}
}
提示这里出错
ConfigureHandler handler = new ConfigureHandler(Configure);
_mapper = SqlMapper.ConfigureAndWatch(handler);
但是换成旧版本的就没错Anders Cui和阿不,我就是学习的你们的文章,但是你们的例子也是旧版本的,不过还是非常感谢。

最佳答案
其它回答(1)
你可以看一下错误在哪里,进而就可以找到原因了
7个月前   回答者:阿不 - 小虾三级
评论
7个月前   Anders Cui :
估计是配置文件的问题
这个改动很大
7个月前   Anders Cui :
改成这样试试:
protected static void InitMapper()
  {
   ConfigureHandler handler = new ConfigureHandler(Configure);
   DomSqlMapBuilder builder = new DomSqlMapBuilder();
   _mapper = builder.ConfigureAndWatch(handler);
  }
   您需要登录以后才能回答!
我的问题    我要提问


快到期问题

> 问题排行榜

有不合适内容,建议去除