Hi, I am trying to set up IBatis.NET.
I have downloaded the sources fromhttp://mybatisnet.googlecode.com/svn/branches/ibatis-1-maintenance/src.
This is my initialization
DomDaoManagerBuilder builder = new DomDaoManagerBuilder();
builder.Configure("dao.config");
IDaoManager daoManager = DaoManager.GetInstance("SqlMapDao");
customerDao = daoManager[typeof(ICustomerDao)];
ICustomerDao cd = (ICustomerDao) customerDao;
The last line throws InvalidCastException "Unable to cast object of type 'Castle.Proxies.IDaoProxy' to type 'SysProt.Dao.ICustomerDao'."
I am not sure, what I did wrong, my dao.config files contains
Here are the definitions of the classes/interfaces:
public interface ICustomerDao
{
Customer Load(long id);
}
public class CustomerDao: BaseDao, ICustomerDao
{
public Customer Load(long id)
{
throw new NotImplementedException();
}
}
public class BaseDao : IDao
{
protected DaoSession GetContext()
{
IDaoManager daoManager = DaoManager.GetInstance(this);
return (daoManager.LocalDaoSession as DaoSession);
}
}
Hi, I think the problem is the inheritance from IDao. ICustomerDAO should inherits from IDao instead BaseDAO.
Regards,
César
--
You received this message because you are subscribed to the Google Groups "mybatisnet-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mybatisnet-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Hi César,
that does not solve the issue
this line executes fine:
IDao customerDao = daoManager[typeof(ICustomerDao)];
customerDao implements IDao.
It is this line which fails:
ICustomerDao cd = (ICustomerDao) customerDao;
I tried adding ICustomerDao: IDao just to be sure and it behaves the same.
Jakub.