日期:2014-05-20  浏览次数:20933 次

无法将类型“IBatisNet.DataMapper.ISqlMapper”隐式转换为“IBatisNet.DataMapper.SqlMapper”。
用Editplus整理编辑完IBatisNet官网的例子Tutorial-1.2.1,使用IBatisNet.DataMapper-bin-1.5.1类库。编译命令如下:
-----------------------------------------------------
csc   /r:../bin/IBatisNet.DataMapper.dll   /r:../bin/nunit.framework.dll   /r:../bin/IBatisNet.Common.dll     /target:library   /out:iBatisTutorial.Model.dll   *.cs
-------------------------------------------------------
错误内容:
------------------------------------------------------

无法将类型“IBatisNet.DataMapper.ISqlMapper”隐式转换为“IBatisNet.DataMapper.SqlMapper”。
存在一个显式转换(是否缺少强制转换?)

---------------------
源码如下:

Helper.cs
---------------------------------------------
using   IBatisNet.DataMapper;

namespace   iBatisTutorial.Model
{
///   <summary>
///   Base   class   for   Helper   objects   (*Helper).  
///   Provides   shared   utility   methods.
///   </summary>
public   abstract   class   Helper
{
public   SqlMapper   Mapper   ()
{
return   IBatisNet.DataMapper.Mapper.Instance   ();
}
}
}
------------------------------------
  PersonHelper.cs
------------------------------------
using   System.Collections;

namespace   iBatisTutorial.Model
{
///   <summary>
///   Helper   class   for   Person   entities.
///   </summary>
public   class   PersonHelper   :   Helper
{
public   Person   Select   (int   id)
{
return   (Person)   Mapper   ().QueryForObject   ( "Select ",   id);
}

public   IList   SelectAll   ()
{
return   Mapper   ().QueryForList   ( "Select ",   null);
}

public   int   Insert   (Person   person)
{
Mapper   ().Insert   ( "Insert ",   person);
//   Insert   is   designed   so   that   it   can   return   the   new   key
//   but   we   are   not   utilizing   that   feature   here
return   1;
}

public   int   Update   (Person   person)
{
return   Mapper   ().Update   ( "Update ",   person);
}

public   int   Delete   (int   id)
{
return   Mapper   ().Delete   ( "Delete ",   id);
}

}
}
------------------------------------
Helpers.cs
------------------------------------
namespace   iBatisTutorial.Model
{
///   <summary>
///   Singleton   "controller "   for   Helper   classes.
///   </summary>
public   class   Helpers
{
private   static   volatile   PersonHelper   _PersonHelper   =   null;

public   static   PersonHelper   Person   ()
{
if   (_PersonHelper   ==   null)
{
lock   (typeof   (PersonHelper))
{
if   (_PersonHelper   ==   null)   //   double-check
_PersonHelper   =   new   PersonHelper   ();
}
}
return   _PersonHelper;