IBatis.Net DataMapper1.6.0 笔记(1)--QuickStart
昨晚四处搜索IBatis.Net的资料..还是博客圆这里最多.^_^
看了福娃 IBatisNet系列二-QuickStart篇 之后 我也试着动手做一做.(没有看过福娃那文章的请先看看)
Very Lucky. (February 1, 2007) The iBATIS.NET team is proud to announce that the BETA release of DataAccess V1.9.0 and DataMapper V1.6.0 are now available.
最新版本的有了一些变动,和福娃哪里展示的有点区别.而且我还偷懒.找了个IBatisNet的代码生成器来生成实体类和配置文件. 第一F5当然是 unsuccessful. 改了几个地方,查了一下最新的DOC.OK了.
实例化SqlMapper的时候居然是不一样的. _mapper = SqlMapper.ConfigureAndWatch (handler); 这句当然首先报错啦.根据官方给的示例.Mapper类要变成这样


public class Mapper

{
private static volatile ISqlMapper _mapper = null;

protected static void Configure(object obj)

{
_mapper = null;
}

protected static void InitMapper()

{
ConfigureHandler handler = new ConfigureHandler(Configure);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
_mapper = builder.ConfigureAndWatch(handler);
}

public static ISqlMapper Instance()

{
if (_mapper == null)

{
lock (typeof(SqlMapper))

{
if (_mapper == null) // double-check

{
InitMapper();
}
}
}
return _mapper;
}

public static ISqlMapper Get()

{
return Instance();
}
}
IList<PersonPerson> list = Mapper.Instance().QueryForList<PersonPerson>("Select", null);
So Funny.
下面开始试一下存储过程.
在这里对福娃表示感谢.^_^
看了福娃 IBatisNet系列二-QuickStart篇 之后 我也试着动手做一做.(没有看过福娃那文章的请先看看)
Very Lucky. (February 1, 2007) The iBATIS.NET team is proud to announce that the BETA release of DataAccess V1.9.0 and DataMapper V1.6.0 are now available.
最新版本的有了一些变动,和福娃哪里展示的有点区别.而且我还偷懒.找了个IBatisNet的代码生成器来生成实体类和配置文件. 第一F5当然是 unsuccessful. 改了几个地方,查了一下最新的DOC.OK了.
实例化SqlMapper的时候居然是不一样的. _mapper = SqlMapper.ConfigureAndWatch (handler); 这句当然首先报错啦.根据官方给的示例.Mapper类要变成这样
public class Mapper
{
private static volatile ISqlMapper _mapper = null;
protected static void Configure(object obj)
{
_mapper = null;
}
protected static void InitMapper()
{
ConfigureHandler handler = new ConfigureHandler(Configure);
DomSqlMapBuilder builder = new DomSqlMapBuilder();
_mapper = builder.ConfigureAndWatch(handler);
}
public static ISqlMapper Instance()
{
if (_mapper == null)
{
lock (typeof(SqlMapper))
{
if (_mapper == null) // double-check
{
InitMapper();
}
}
}
return _mapper;
}
public static ISqlMapper Get()
{
return Instance();
}
}还有多了泛型的支持.之前的版本不知道是否支持泛型,反正我是用泛型的方法.福娃那个好像不是2.0的.^_^
IList<PersonPerson> list = Mapper.Instance().QueryForList<PersonPerson>("Select", null);So Funny.
下面开始试一下存储过程.
在这里对福娃表示感谢.^_^
