IBatis框架 利用select @@Identity 获取新增记录ID
<insert id="InsertPurchaseEvaluations" parameterClass="PurchaseEvaluations">
INSERT INTO PurchaseEvaluations(
ApplyMoneyID,
PurchaseID,
PurchaseName,
AddUserID,
AddUserName,
AddTime,
AverageScoreValue,
EvaluationRemark,
PurchaseLevel,
EvaluationType)
VALUES(
#ApplyMoneyID#,
#PurchaseID#,
#PurchaseName#,
#AddUserID#,
#AddUserName#,
#AddTime#,
#AverageScoreValue#,
#EvaluationRemark#,
#PurchaseLevel#,
#EvaluationType#)
<selectKey property="Id" resultClass="int" type="post">
select @@Identity as Id
</selectKey>
</insert>
public int InsertPurchaseEvaluations(PurchaseEvaluations purchaseEvaluations)
{
mapper.Insert("InsertPurchaseEvaluations", purchaseEvaluations);
return purchaseEvaluations.Id;
}