Closed CRC32EX closed 3 years ago
Hello @CRC32EX ,
It's currently not supported. I will look with my developer how we could support it.
Best Regards,
Jon
Hello @CRC32EX ,
Here is the code you can use which will do the same behavior:
DapperPlusManager.Entity<EntitySimple>().Table("users").Key(x => x.ID, "id");
var users = new List<User>()
{
new User{ Id = 2, Name = "swan" },
new User{ Id = 4, Name = "bear" }
};
conn.UseBulkOptions(x => x.InsertIfNotExists = true).BulkInsert(users);
It doesn't use the IGNORE
keyword but instead, check if the data already exists or not.
Is that an alternative solution that could work for you?
Best Regards,
Jon
It works well.
In my situation IGNORE
is not needed anymore.
When I really needed IGNORE
keyword, i will open this issue again.
In my situation, Key
attributes also works well.
Thank you.
using MySqlConnector;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Z.Dapper.Plus;
namespace Test
{
[Table("users")]
class User
{
[Key]
[Column("id")]
public ulong Id { get; set; }
[Column("name")]
public string Name { get; set; }
}
class Program
{
const string Connstr = "userid=root;password=MYPASSWORD;database=MYDB;Host=127.0.0.1;";
static MySqlConnection Connect()
{
var conn = new MySqlConnection(Connstr);
conn.Open();
return conn;
}
static void Main()
{
using var conn = Connect();
var users = new List<User>()
{
new User { Id = 2, Name = "swan" },
new User { Id = 4, Name = "bear" }
};
conn.UseBulkOptions(x => x.InsertIfNotExists = true).BulkInsert(users);
}
}
}
Question
IGNORE
is supported? I want write like this.Program.cs
What i want to do example (SQL)
2, 'swan'
and4, 'bear'
but, i want to keep exists data(in this case2, 'dog'
).My Environment