public static UpdateOf <T> SetJsonb <T, TProperty>( this UpdateOf <T> updateOf, Expression <Func <T, TProperty> > propertySelector, Expression <Func <TProperty, object> > jsonbPropertySelector, object value) where T : class { return(updateOf); }
private static PgSqlCommand FromUpdate <T>(UpdateOf <T> update, string tableName = null) where T : class { var type = typeof(T); tableName ??= type.GetCustomAttributes(typeof(TableAttribute), true).FirstOrDefault() is TableAttribute attr ? attr.Name : type.Name; var byName = ExpressionHelper.GetPropertyInfo(update.UpdateBy.Property).Name; var @params = update.Updates .Select(selector => selector switch { JsonbSelector <T> jsonb => VisitJsonbSelector(jsonb), _ => VisitSelector(selector) })
public async Task HandleUpdateAsync <T>(UpdateOf <T> updateOf) where T : class { if (!_storage.TryGetValue(updateOf.UpdateBy.Value, out var value)) { return; } if (value is T) { foreach (var update in updateOf.Updates) { if (update.Property.Body is MemberExpression memberSelectorExpression) { var property = memberSelectorExpression.Member as PropertyInfo; if (property != null) { property.SetValue(value, update.Value, null); } } } } }
public async Task HandleUpdateAsync <T>(UpdateOf <T> update) where T : class { var sqlCommand = _sqlVisitor.Visit(update); var commandDefinition = new CommandDefinition(sqlCommand.Text, new DynamicParameters(sqlCommand.Params)); await _dbConnection.ExecuteAsync(commandDefinition); }
public static UpdateOf <T> SetJsonb <T>( this UpdateOf <T> updateOf, Expression <Func <T, object> > propertySelector, string jsonbPropertyName, object value) where T : class => new JsonbUpdateOf <T>(updateOf, new JsonbSelector <T>(propertySelector, jsonbPropertyName, value));
public JsonbUpdateOf(UpdateOf <T> wrapped, JsonbSelector <T> selector) : base() { _idSelector = wrapped.UpdateBy; _updates.AddRange(wrapped.Updates); _updates.Add(selector); }
public ISqlCommand Visit <T>(UpdateOf <T> update) where T : class => FromUpdate(update);