1.sqlmap:
在<insert>中添加<select>节点,resultClass为返回的字段类型
主键为ClientID
<insert id="InsertClient" resultMap="ClientList">
insert into TSos_ClientInfo(ClientNo,ShortName,FullName,Type,ClientManager,Address,InvoiceInformation,remar)values(#ClientNo#,#ShortName#,#FullName#,#Type#,#ClientManager#,#Address#,#InvoiceInformation#,#Remar#)
<selectKey resultClass="int" type="post" property="ClientID">
select @@IDENTITY as value
</selectKey>
</insert>
2.BLL:
返回主键=(int)SqlMap.Insert("selectID", object);
public int InsertClient(string ClientInfo, DateTime edittime)
{
string[] list = ClientInfo.Split('^');
Model.Table.Client client = new Model.Table.Client();
client.ClientNo = list[0].ToString();
client.Type = list[1].ToString();
client.ShortName = list[2].ToString();
client.FullName = list[3].ToString();
client.ClientManager = list[4].ToString();
client.Address = list[5].ToString();
client.InvoiceInformation = list[6].ToString();
client.Remar = list[7].ToString();
client.EditTime = edittime;
int ClientID = (int)SqlMap.Insert("InsertClient", client);
return ClientID;
}