IBatisNet Update问题请教.想实现点击Button1更新指定ID的用户的姓和名.按以下方法为何无法更新?改如何修改?谢谢!!!1.Person.xml配置:
<update id="UpdatePer" parameterClass ="int" resultClass="Person">
<![CDATA[ update person set
PER_FIRST_NAME =#FIRSTNAME#,
PER_Last_NAME =#LASTNAME#
where
PER_ID = #ID# ]]>
</update>
2.Button1_Click事件:
protected void Button1_Click(object sender, EventArgs e)
{
Mapper.Instance().BeginTransaction();
Person person = new Person();
person.FIRSTNAME = this.TextBox2.Text.ToString();
person.LASTNAME = this.TextBox1.Text.ToString();
Mapper.Instance().Update("UpdatePer",person);
Mapper.Instance().CommitTransaction();
}
3.Mapper.cs类:
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();
}
}
<update id="UpdatePer" parameterClass ="int" resultClass="Person">
<![CDATA[ update person set
PER_FIRST_NAME =#FIRSTNAME#,
PER_Last_NAME =#LASTNAME#
where
PER_ID = #ID# ]]>
</update>
2.Button1_Click事件:
protected void Button1_Click(object sender, EventArgs e)
{
Mapper.Instance().BeginTransaction();
Person person = new Person();
person.FIRSTNAME = this.TextBox2.Text.ToString();
person.LASTNAME = this.TextBox1.Text.ToString();
Mapper.Instance().Update("UpdatePer",person);
Mapper.Instance().CommitTransaction();
}
3.Mapper.cs类:
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();
}
}
检查映射文件是否正确
我也做了一个遇到了问题是,
走到Mapper.Instance().Update()就不走了,不知道为什么?
you know?