public async Task <bool> UpdateAsync <TEntity>(Expression <Func <TEntity, bool> > condition, params Expression <Func <TEntity, object> >[] setExpressions) where TEntity : Entity, new() { var builder = new QueryBuilder <TEntity>(connectorQuery); var expressions = from c in setExpressions select((c.Body as UnaryExpression)?.Operand as MethodCallExpression) ?? c.Body as MethodCallExpression; var query = builder.BuildUpdate(expressions.ToArray(), true); query = builder.BuildUpdate(condition); return(await ExecuteAsync(query)); }
public ValueTask <bool> UpdateAllAsync <TEntity>(params Expression <Func <TEntity, object> >[] setExpressions) where TEntity : Entity, new() { var builder = new QueryBuilder <TEntity>(Connector.Query); var expressions = from c in setExpressions select((c.Body as UnaryExpression)?.Operand as MethodCallExpression) ?? c.Body as MethodCallExpression; builder.BuildUpdate(expressions.ToArray(), null); return(ExecuteAsync(builder)); }
public async Task <bool> UpdateAsync <TEntity>(TEntity entity) where TEntity : Entity, new() { var type = typeof(TEntity); var properties = type.GetReadWriteProperties(); var primaryKeys = type.GetTypeInfo().DeclaredProperties.Where(p => p.HasAttribute <PrimaryKeyAttribute>() || p.GetName() == "Id" || p.GetName() == type.Name + "Id").ToArray(); var builder = new QueryBuilder <TEntity>(connectorQuery); var query = builder.BuildUpdate(entity, properties, primaryKeys); return(await ExecuteAsync(query)); }