PomeloFoundation / Lolita

A light-weight extension which provides bulk update and delete operations for Entity Framework Core.
MIT License
118 stars 23 forks source link

update No mapping to a relational type can be found for the CLR type 'CancellationToken'. #18

Open lsczyzkb opened 6 years ago

lsczyzkb commented 6 years ago

public Task BatchUpdateAsync<TProperty>(Expression<Func<TEntity, bool>> predicate, Expression<Func<TEntity, TProperty>> Property, object value) { return Context.Set<TEntity>().Where(predicate).SetField(Property).WithValue(value).UpdateAsync(); }

error No mapping to a relational type can be found for the CLR type 'CancellationToken'.

he1a2s0 commented 6 years ago

The parameters of db.Database.ExecuteSqlCommandAsync(...) in method DefaultLolitaUpdateExecutor.ExecuteAsync(...) are in the wrong order,add a custom class implement ILolitaUpdateExecutor in your project and replace the default DefaultLolitaUpdateExecutor with it can resolve this issue. Only one different place: return db.Database.ExecuteSqlCommandAsync(sql, cancellationToken, param); should be changed to return db.Database.ExecuteSqlCommandAsync(sql, param, cancellationToken);