mirror of
https://github.com/DapperLib/Dapper.git
synced 2026-10-17 05:12:13 +08:00
Fix missing Firebase Async, issue #695
TODO: All of these need race love in V2, complete re-vamp.
This commit is contained in:
@@ -429,4 +429,26 @@ public partial class SQLiteAdapter
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
public partial class FbAdapter
|
||||
{
|
||||
public async Task<int> InsertAsync(IDbConnection connection, IDbTransaction transaction, int? commandTimeout, string tableName, string columnList, string parameterList, IEnumerable<PropertyInfo> keyProperties, object entityToInsert)
|
||||
{
|
||||
var cmd = $"insert into {tableName} ({columnList}) values ({parameterList})";
|
||||
await connection.ExecuteAsync(cmd, entityToInsert, transaction, commandTimeout);
|
||||
|
||||
var propertyInfos = keyProperties as PropertyInfo[] ?? keyProperties.ToArray();
|
||||
var keyName = propertyInfos.First().Name;
|
||||
var r = await connection.QueryAsync($"SELECT FIRST 1 {keyName} ID FROM {tableName} ORDER BY {keyName} DESC", transaction: transaction, commandTimeout: commandTimeout);
|
||||
|
||||
var id = r.First().ID;
|
||||
if (id == null) return 0;
|
||||
if (!propertyInfos.Any()) return Convert.ToInt32(id);
|
||||
|
||||
var idp = propertyInfos.First();
|
||||
idp.SetValue(entityToInsert, Convert.ChangeType(id, idp.PropertyType), null);
|
||||
|
||||
return Convert.ToInt32(id);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user