1. 批量插入 public async Task CreateBusinessItemAsync(IEnumerable<BusinessItemsEntity> businessItemsEntities) { var bizid = businessItemsEntities.First(). ...
1. 批量插入
public async Task CreateBusinessItemAsync(IEnumerable<BusinessItemsEntity> businessItemsEntities)
{
var bizid = businessItemsEntities.First().BizId;
await _connection.DbConnection.ExecuteAsync("delete from BusinessItems where bizid=@BizId;", new { bizId= bizid });
string sql = @"INSERT INTO BusinessItems
([BizId]
,[ExpiredTime]
,[DisposeTime]
,[Remark]
,[ProductCategoryCode],Status)
values
(@BizId
,@ExpiredTime
,@DisposeTime,@Remark, @ProductCategoryCode,@Status);";
await _connection.DbConnection.ExecuteAsync(sql, businessItemsEntities);對, 就是這麼暴躁, 直接把列表傳進去就完事了
2. 批量更新.
參考 http://www.cnblogs.com/wuyunblog/p/9456756.html
1. where in 批量更新, 這時候所有需要更新的值都是一個同樣的值
2. 如果每條語句更新的值都不一樣呢
3. 模糊查詢
方法1 https://stackoverflow.com/questions/6030099/does-dapper-support-the-like-operator
db.Query<Remitente>("SELECT * FROM Remitentes WHERE Nombre LIKE @n", new { n = "%" + nombre + "%" }) .ToList();
方法2