1 条件判断是否要加过滤条件

public static IQueryable<T> WhereIf<T>(
this IQueryable<T> source,
Expression<Func<T, bool>> predicate,
bool condition)
{
source.CheckNotNull<IQueryable<T>>(nameof (source));
predicate.CheckNotNull<Expression<Func<T, bool>>>(nameof (predicate));
return condition ? source.Where<T>(predicate) : source;
}

 

public static void Update<TEntity>(this DbContext dbContext, object entitiy, object id) where TEntity : EntityBase
{
dbContext.CheckNotNull<DbContext>(nameof (dbContext));
TEntity entity = dbContext.Set<TEntity>().Find(id);
dbContext.Entry<TEntity>(entity).CurrentValues.SetValues(entitiy);
}

2 swagger文档

https://www.cnblogs.com/dukang1991/p/5627673.html

https://note.youdao.com/ynoteshare1/index.html?id=87b3d19683d150102744d4c4cc2f4c98&type=note