using FreeSql.Internal; using System.Linq; namespace FreeSql.MySql.Curd { class MySqlInsertOrUpdate : Internal.CommonProvider.InsertOrUpdateProvider where T1 : class { public MySqlInsertOrUpdate(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression) : base(orm, commonUtils, commonExpression) { } public override string ToSql() { if (_source?.Any() != true) return null; var insert = _orm.Insert() .AsTable(_tableRule).AsType(_table.Type) .WithConnection(_connection) .WithTransaction(_transaction) .NoneParameter(true) as Internal.CommonProvider.InsertProvider; insert._source = _source; var sql = new OnDuplicateKeyUpdate(insert).ToSql(); _params = insert._params; return sql; } } }