|
@@ -1,5 +1,6 @@
|
|
using DW5S.Entity;
|
|
using DW5S.Entity;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
+using Microsoft.EntityFrameworkCore.ChangeTracking;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq;
|
|
@@ -22,6 +23,18 @@ namespace DW5S.Repostory
|
|
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate = null);
|
|
Task<T> FirstOrDefaultAsync(Expression<Func<T, bool>> predicate = null);
|
|
Task<T> AddOrUpdateAsync(T entity);
|
|
Task<T> AddOrUpdateAsync(T entity);
|
|
Task AddOrUpdateAsync(IEnumerable<T> entitis);
|
|
Task AddOrUpdateAsync(IEnumerable<T> entitis);
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 修改某些字段
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <typeparam name="TProperty"></typeparam>
|
|
|
|
+ /// <param name="predicate"></param>
|
|
|
|
+ /// <param name="propertyExpression"></param>
|
|
|
|
+ /// <param name="value"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ Task<int> UpdatePropAsync<TProperty>(Expression<Func<T, bool>> predicate, Func<T, TProperty> propertyExpression, TProperty value);
|
|
|
|
+
|
|
|
|
+
|
|
Task<int> DeleteAsync(T entity);
|
|
Task<int> DeleteAsync(T entity);
|
|
Task<int> DeleteAsync(IEnumerable<T> entitis);
|
|
Task<int> DeleteAsync(IEnumerable<T> entitis);
|
|
|
|
|
|
@@ -157,5 +170,12 @@ namespace DW5S.Repostory
|
|
else
|
|
else
|
|
return dbSet.Where(predicate).MaxBy(selector);
|
|
return dbSet.Where(predicate).MaxBy(selector);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public async Task<int> UpdatePropAsync<TProperty>(Expression<Func<T, bool>> predicate, Func<T, TProperty> propertyExpression, TProperty value)
|
|
|
|
+ {
|
|
|
|
+ return await dbSet.Where(predicate)
|
|
|
|
+ .ExecuteUpdateAsync(setters => setters.SetProperty(propertyExpression, value));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|