コード例 #1
0
 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);
 }
コード例 #2
0
        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)
            })
コード例 #3
0
        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);
                        }
                    }
                }
            }
        }
コード例 #4
0
 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);
 }
コード例 #5
0
 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));
コード例 #6
0
 public JsonbUpdateOf(UpdateOf <T> wrapped, JsonbSelector <T> selector) : base()
 {
     _idSelector = wrapped.UpdateBy;
     _updates.AddRange(wrapped.Updates);
     _updates.Add(selector);
 }
コード例 #7
0
 public ISqlCommand Visit <T>(UpdateOf <T> update) where T : class => FromUpdate(update);