首页 > 技术文章 > ServiceStack.Ormlit 使用Insert的时候自增列不会被赋值

shaoming01 2014-03-26 14:59 原文

 

Insert签名是这样的,将第2个参数设置为true就会返回刚插入的自增列ID了,然后可以手工赋值到对象上面去

public static long Insert<T>(this IDbConnection dbConn, T obj, bool selectIdentity = false)
{
return dbConn.Exec(dbCmd => dbCmd.Insert(obj, selectIdentity));
}

推荐阅读