Exemplo n.º 1
0
        public void DeleteWhere(TableName table, IWhereFragment @where)
        {
            if (table == null) throw new ArgumentNullException(nameof(table));
            if (@where == null) throw new ArgumentNullException(nameof(@where));

            var whereClause = @where.ToSql(_command);
            var call = new DeleteWhereCall(table, whereClause);
            _calls.Add(call);
        }
Exemplo n.º 2
0
        public static string AppendWhere(this string sql, IWhereFragment where, NpgsqlCommand command)
        {
            if (where == null)
            {
                return(sql);
            }

            return(sql + " where " + where.ToSql(command));
        }
Exemplo n.º 3
0
        public void AddParameters(IBatchCommand batch)
        {
            var patchJson    = batch.Serializer.ToCleanJson(_patch);
            var patchParam   = batch.AddParameter(patchJson, NpgsqlDbType.Jsonb);
            var versionParam = batch.AddParameter(CombGuidIdGeneration.NewGuid(), NpgsqlDbType.Uuid);

            var where = _fragment.ToSql(batch.Command);

            _sql = $@"
update {_document.Table.QualifiedName} as d 
set data = {_transform.Function.QualifiedName}(data, :{patchParam.ParameterName}), {DocumentMapping.LastModifiedColumn} = (now() at time zone 'utc'), {DocumentMapping.VersionColumn} = :{versionParam.ParameterName}
where {where}";
        }
Exemplo n.º 4
0
        public void RegisterUpdate(UpdateBatch batch)
        {
            batch.AddCall(cmd =>
            {
                var patchJson  = batch.Serializer.ToCleanJson(_patch);
                var patchParam = cmd.AddParameter(patchJson, NpgsqlDbType.Jsonb);
                var where      = _fragment.ToSql(cmd.Command);

                _sql =
                    $"update {_document.Table.QualifiedName} as d set data = {_transform.Function.QualifiedName}(data, :{patchParam.ParameterName}) where {where}";

                return(this);
            });
        }
Exemplo n.º 5
0
        public void DeleteWhere(TableName table, IWhereFragment @where)
        {
            if (table == null)
            {
                throw new ArgumentNullException(nameof(table));
            }
            if (@where == null)
            {
                throw new ArgumentNullException(nameof(@where));
            }

            var whereClause = @where.ToSql(Command);
            var call        = new DeleteWhereCall(table, whereClause);

            AddCall(call);
        }
Exemplo n.º 6
0
 public string ToSql(NpgsqlCommand command)
 {
     return($"NOT({_inner.ToSql(command)})");
 }
Exemplo n.º 7
0
        void IStorageOperation.AddParameters(IBatchCommand batch)
        {
            var whereClause = _where.ToSql(batch.Command);

            Sql = Sql.Replace("?", whereClause);
        }
Exemplo n.º 8
0
 public void DeleteWhere(string tableName, IWhereFragment @where)
 {
     var whereClause = @where.ToSql(_command);
     var call = new DeleteWhereCall(tableName, whereClause);
     _calls.Add(call);
 }