- 修复 Xugu Insert + AsTable + ExecuteIdentity bug;

This commit is contained in:
2881099
2023-11-01 15:12:23 +08:00
parent af235783c6
commit 448b25c479
2 changed files with 4 additions and 114 deletions

View File

@ -63,7 +63,7 @@ namespace FreeSql.Xugu.Curd
//using (var command = cmd.Connection.CreateCommand()) {
//command.CommandType = CommandType.Text;
var sqlIdentity = $"SELECT {_commonUtils.QuoteSqlName(identCols.First().Value.Attribute.Name)} FROM {_table.DbName} WHERE \"ROWID\"='{rowid}'";
var sqlIdentity = $"SELECT {_commonUtils.QuoteSqlName(identCols.First().Value.Attribute.Name)} FROM {_commonUtils.QuoteSqlName(TableRuleInvoke())} WHERE \"ROWID\"='{rowid}'";
//command.CommandText = sql;
@ -91,11 +91,6 @@ namespace FreeSql.Xugu.Curd
protected override List<T1> RawExecuteInserted()
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return null;
@ -119,7 +114,7 @@ namespace FreeSql.Xugu.Curd
{
var rowid = (cmd as XGCommand).get_insert_rowid();
var sqlIdentity = $"SELECT {sbColumn} FROM {_table.DbName} WHERE \"ROWID\"='{rowid}'";
var sqlIdentity = $"SELECT {sbColumn} FROM {_commonUtils.QuoteSqlName(TableRuleInvoke())} WHERE \"ROWID\"='{rowid}'";
ret = _orm.Ado.Query<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sqlIdentity, _commandTimeout, _params);
@ -147,8 +142,6 @@ namespace FreeSql.Xugu.Curd
async protected override Task<long> RawExecuteIdentityAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return 0;
@ -170,7 +163,7 @@ namespace FreeSql.Xugu.Curd
await _orm.Ado.ExecuteNonQueryAsync(_connection, _transaction, CommandType.Text, sql, _commandTimeout, cmd =>
{
var rowid = (cmd as XGCommand).get_insert_rowid();
var sqlIdentity = $"SELECT {_commonUtils.QuoteSqlName(identCols.First().Value.Attribute.Name)} FROM {_table.DbName} WHERE \"ROWID\"='{rowid}'";
var sqlIdentity = $"SELECT {_commonUtils.QuoteSqlName(identCols.First().Value.Attribute.Name)} FROM {_commonUtils.QuoteSqlName(TableRuleInvoke())} WHERE \"ROWID\"='{rowid}'";
if (!long.TryParse(_orm.Ado.ExecuteScalar(CommandType.Text, sqlIdentity, _params).ToString(), out ret))
{
@ -193,11 +186,6 @@ namespace FreeSql.Xugu.Curd
}
async protected override Task<List<T1>> RawExecuteInsertedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return null;
@ -219,7 +207,7 @@ namespace FreeSql.Xugu.Curd
{
var rowid = (cmd as XGCommand).get_insert_rowid();
var sqlIdentity = $"SELECT {sbColumn} FROM {_table.DbName} WHERE \"ROWID\"='{rowid}'";
var sqlIdentity = $"SELECT {sbColumn} FROM {_commonUtils.QuoteSqlName(TableRuleInvoke())} WHERE \"ROWID\"='{rowid}'";
ret = _orm.Ado.Query<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sqlIdentity, _commandTimeout, _params);
return Task.CompletedTask;