Exemple #1
0
        public IQueryFactoryResult Process(IQueryContainer container)
        {
            var query = new StringBuilder();

            if (container.AccessLayer.DbAccessType.HasFlag(DbAccessType.MsSql) ||
                container.AccessLayer.DbAccessType.HasFlag(DbAccessType.MySql))
            {
                query.Append($"UPDATE [{Alias.GetAlias()}] SET ");
                query
                .Append(
                    ColumnAssignments
                    .Select(
                        columnAssignment =>
                        $"{Alias.GetAlias().EnsureAlias()}.{columnAssignment.Column.EnsureAlias()} = {columnAssignment.Value}")
                    .Aggregate((e, f) => e + ", " + f)
                    );
                query.Append($" FROM {_target.GetAlias().EnsureAlias()} AS {Alias.GetAlias().EnsureAlias()}");
            }
            else
            {
                query.Append($"UPDATE {_target.GetAlias().EnsureAlias()} SET ");
                query
                .Append(
                    ColumnAssignments
                    .Select(
                        columnAssignment =>
                        $"{columnAssignment.Column.EnsureAlias()} = {columnAssignment.Value}")
                    .Aggregate((e, f) => e + ", " + f)
                    );
                query.Append($"");
            }

            return(new QueryFactoryResult(query.ToString(),
                                          ColumnAssignments.SelectMany(f => f.QueryParameters).ToArray()));
        }
Exemple #2
0
 public IQueryFactoryResult Process(IQueryContainer container)
 {
     if (container.AccessLayer.DbAccessType.HasFlag(DbAccessType.SqLite))
     {
         return(new QueryFactoryResult($"DELETE FROM {_target.GetAlias().EnsureAlias()} "));
     }
     else
     {
         return(new QueryFactoryResult($"DELETE {Alias.GetAlias().EnsureAlias()} " +
                                       $"FROM {_target.GetAlias().EnsureAlias()} " +
                                       $"AS {Alias.GetAlias().EnsureAlias()}"));
     }
 }
        public IQueryFactoryResult Process(IQueryContainer container)
        {
            var query = new StringBuilder();

            switch (container.AccessLayer.DbAccessType)
            {
            case DbAccessType.MsSql:
            case DbAccessType.MySql:
                query.Append($"UPDATE [{Alias.GetAlias()}] SET ");
                query
                .Append(
                    ColumnAssignments
                    .Select(
                        columnAssignment =>
                        $"[{Alias.GetAlias().TrimAlias()}].[{columnAssignment.Column.TrimAlias()}] = {columnAssignment.Value}")
                    .Aggregate((e, f) => e + ", " + f)
                    );
                query.Append($" FROM [{_target.GetAlias().TrimAlias()}] AS [{Alias.GetAlias().TrimAlias()}]");
                break;

            case DbAccessType.Experimental:
            case DbAccessType.Unknown:
            case DbAccessType.OleDb:
            case DbAccessType.Obdc:
            case DbAccessType.SqLite:
                query.Append($"UPDATE [{_target.GetAlias().TrimAlias()}] SET ");
                query
                .Append(
                    ColumnAssignments
                    .Select(
                        columnAssignment =>
                        $"[{columnAssignment.Column.TrimAlias()}] = {columnAssignment.Value}")
                    .Aggregate((e, f) => e + ", " + f)
                    );
                query.Append($"");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(new QueryFactoryResult(query.ToString(),
                                          ColumnAssignments.SelectMany(f => f.QueryParameters).ToArray()));
        }
Exemple #4
0
        public IQueryFactoryResult Process(IQueryContainer container)
        {
            switch (container.AccessLayer.DbAccessType)
            {
            case DbAccessType.Experimental:
            case DbAccessType.Unknown:
            case DbAccessType.MsSql:
            case DbAccessType.MySql:
            case DbAccessType.OleDb:
            case DbAccessType.Obdc:
                return(new QueryFactoryResult($"DELETE [{Alias.GetAlias().TrimAlias()}] " +
                                              $"FROM [{_target.GetAlias().TrimAlias()}] " +
                                              $"AS [{Alias.GetAlias().TrimAlias()}]"));

            case DbAccessType.SqLite:
                return(new QueryFactoryResult($"DELETE FROM [{_target.GetAlias().TrimAlias()}] "));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }