public class User
{
private string _user_id;
private string _user_name;
private string _birthday;
public string user_id
{
get
{
return this._user_id;
}
set
{
this._user_id = value;
}
public string user_name
{
get
{
return this._user_name;
}
set
{
this._user_name = value;
}
}
public string birthday
{
get
{
return this._birthday;
}
set
{
this._birthday = value;
}
}
}
public class DateTimeHandler:ITypeHandlerCallback
{
#region ITypeHandlerCallback 成员
public object ValueOf(string s)
{
if(s!=null && s.Length>0)
return Convert.ToDateTime(s);
return null;
}
public object GetResult(IResultGetter getter)
{
if(getter!=null)
return getter.Value.ToString();
return null;
}
public void SetParameter(IParameterSetter setter, object parameter)
{
if(parameter==null)
{
setter.Value=System.DBNull.Value;
}
else
{
setter.Value=Convert.ToDateTime(parameter);
}
}
#endregion
}
<?xml version="1.0" encoding="UTF-8"?>
<sqlMap namespace="User" xmlns="http://ibatis.apache.org/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
<typeAlias alias="User" type="test.Breed,test"/>
<typeAlias alias="DateTimeHandler" type="test.DateTimeHandler,test" />
</alias>
<resultMaps>
<resultMap id="UserResult" class="User">
<result property="user_id" column="user_id"/>
<result property="user_name" column="user_name"/>
<result property="birthday" column="birthday" typeHandler="DateTimeHandler"/>
</resultMap>
</resultMaps>
<statements>
<insert id="InsertUser" parameterClass="User">
insert into User
( user_id, user_name, birthday)
values
( #user_id#, #user_name#, #birthday#)
</insert>
<update id="UpdateUser" parameterClass="User">
update User
set user_name=#user_name#,
birthday=#brd_birthday#
where user_id = #user_id#
</update>
<select id="GetUsers" resultMap="UserResult">
select * from User
</select>
<select id="GetUserByID" resultMap="UserResult" paramterClass="string">
select * from User where user_id=#user_id#
</select>
</statements>
</sqlMap>
分享到:
相关推荐
IBatisNet和NHibernate模版
IBatisNet-执行存储过程详细实例 IBatisNet-执行存储过程详细实例 IBatisNet-执行存储过程详细实例 IBatisNet-执行存储过程详细实例 IBatisNet-执行存储过程详细实例
iBATISNet Database Layer!这个框架将让你能够更好的在dotnet应用中设计和实现实体层。这个框架有两个主要的组成部分,一个是SQL Maps,另一个是Data Access Objects。下面是一个简单的iBATISNet应用架构。 项目中...
Ibatisnet介绍和使用
IBatisNet 框架 项目实例
C# winform ibatisnet datagridview数据库分页。 使用前先在数据库中创建sys_user表。字段看配置文件。
对于IBatisNet的新手还是很有帮助的
理解ibatisnet机制,从入门到会只要几天时间,ORM模式很大程度上改善了代码的质量,效率更高,代码更少。
IBatisNet C# .net 入门 配置 使用的例子 有入门到精通 请用word2007打开
通过研究IBatisNet源码主要是操作守护静态类来实现多源数据库的连接操作 IBatisNet同时连接多个数据库(orcl、sqllite、sqlserver) 并附带如何保存图片到ORACLE数据库
C#开发 MonoRail+IBatisNet +Velocity+vs2010的项目实例,初学者配置起来比较繁琐,配置好使用起来发现IBatisNet 还是很强大的!
IBatisNet+Castle项目实例
ibatisnet的dll和相关操作配置文档,很全面
利用IBatisNet所建的开发框架。有利于程序员的快速开发。减少常用操作数据库的工作量
C#开发 ibatisnet+monorail+vs2010的项目实例
完整的iBatisNet配置SQLlite例子,有完整实体类和一个简单的查询测试方法。希望帮助各位快速构建项目
Ibatisnet大合集整理的...IbatisnetIbatisnetIbatisnet....
IBatisNet在.NET中的使用总结
IBatisNet源代码 反编译出来的。。编译通过,最新版本。
详细IbatisNet配置,以及使用其调用存储过程