Inheritance: SqlAliasedExpression
Exemple #1
0
 public SqlUpdateExpression(SqlTableExpression table, IReadOnlyList <Expression> assignments, Expression where)
     : base(typeof(void))
 {
     this.Table       = table;
     this.Assignments = assignments;
     this.Where       = where;
 }
 public SqlDeleteExpression(SqlTableExpression table, string alias, Expression where)
     : base(typeof(void))
 {
     this.Where = where;
     this.Alias = alias;
     this.Table = table;
 }
 public SqlUpdateExpression(SqlTableExpression table, IReadOnlyList<Expression> assignments, Expression where)
     : base(typeof(void))
 {
     this.Table = table;
     this.Assignments = assignments;
     this.Where = where;
 }
Exemple #4
0
 public SqlDeleteExpression(SqlTableExpression table, string alias, Expression where)
     : base(typeof(void))
 {
     this.Where = where;
     this.Alias = alias;
     this.Table = table;
 }
 public SqlInsertIntoExpression(SqlTableExpression table, IReadOnlyList<string> columnNames, IReadOnlyList<string> returningAutoIncrementColumnNames, IReadOnlyList<Expression> valueExpressions)
     : base(typeof(void))
 {
     this.Table = table;
     this.ColumnNames = columnNames;
     this.ReturningAutoIncrementColumnNames = returningAutoIncrementColumnNames;
     this.ValueExpressions = valueExpressions;
 }
Exemple #6
0
 public SqlInsertIntoExpression(SqlTableExpression table, IReadOnlyList <string> columnNames, IReadOnlyList <string> returningAutoIncrementColumnNames, IReadOnlyList <Expression> valueExpressions)
     : base(typeof(void))
 {
     this.Table       = table;
     this.ColumnNames = columnNames;
     this.ReturningAutoIncrementColumnNames = returningAutoIncrementColumnNames;
     this.ValueExpressions = valueExpressions;
 }
		public SqlCreateTableExpression(SqlTableExpression table, bool ifNotExist, IReadOnlyList<SqlColumnDefinitionExpression> columnExpressions, IReadOnlyList<Expression> tableConstraintExpressions)
			: base(typeof(void))
		{
			this.Table = table;
			this.IfNotExist = ifNotExist;
			this.TableConstraints = tableConstraintExpressions;
			this.ColumnDefinitionExpressions = columnExpressions;
		}
Exemple #8
0
 public SqlCreateTableExpression(SqlTableExpression table, bool ifNotExist, IReadOnlyList <SqlColumnDefinitionExpression> columnExpressions, IReadOnlyList <Expression> tableConstraintExpressions)
     : base(typeof(void))
 {
     this.Table                       = table;
     this.IfNotExist                  = ifNotExist;
     this.TableConstraints            = tableConstraintExpressions;
     this.ColumnDefinitionExpressions = columnExpressions;
 }
		protected override Expression VisitTable(SqlTableExpression table)
		{
			if (table.Name != updateTableName || !inUpdate)
			{
				return base.VisitTable(table);
			}

			return new SqlSelectExpression(table.Type, table.Alias, new SqlColumnDeclaration[0], table.ChangeAlias(null), null, null);
		}
		public SqlReferencesColumnExpression(SqlTableExpression referencedTable, SqlColumnReferenceDeferrability deferrability, IReadOnlyList<string> referencedColumnNames, SqlColumnReferenceAction onDelete, SqlColumnReferenceAction onUpdate)
			: base(typeof(void))
		{
			this.OnDeleteAction = onDelete;
			this.OnUpdateAction = onUpdate;
			this.ReferencedTable = referencedTable;
			this.Deferrability = deferrability;
			this.ReferencedColumnNames = referencedColumnNames;
		}
 public SqlCreateTableExpression(SqlTableExpression table, bool ifNotExist, IReadOnlyList<SqlColumnDefinitionExpression> columnExpressions, IReadOnlyList<Expression> tableConstraintExpressions, IReadOnlyList<SqlTableOption> tableOptions = null)
     : base(typeof(void))
 {
     this.Table = table;
     this.IfNotExist = ifNotExist;
     this.TableOptions = tableOptions ?? Enumerable.Empty<SqlTableOption>().ToReadOnlyList();
     this.TableConstraints = tableConstraintExpressions;
     this.ColumnDefinitionExpressions = columnExpressions;
 }
        public SqlReferencesExpression ChangeReferencedTable(SqlTableExpression value)
        {
            if (ReferenceEquals(this.ReferencedTable, value))
            {
                return(this);
            }

            return(new SqlReferencesExpression(value, this.Deferrability, this.ReferencedColumnNames, this.OnDeleteAction, this.OnUpdateAction));
        }
Exemple #13
0
 public SqlCreateTableExpression(SqlTableExpression table, bool ifNotExist, IReadOnlyList <SqlColumnDefinitionExpression> columnExpressions, IReadOnlyList <Expression> tableConstraintExpressions, IReadOnlyList <SqlTableOption> tableOptions = null)
     : base(typeof(void))
 {
     this.Table                       = table;
     this.IfNotExist                  = ifNotExist;
     this.TableOptions                = tableOptions ?? Enumerable.Empty <SqlTableOption>().ToReadOnlyCollection();
     this.TableConstraints            = tableConstraintExpressions;
     this.ColumnDefinitionExpressions = columnExpressions;
 }
 public SqlReferencesExpression(SqlTableExpression referencedTable, SqlColumnReferenceDeferrability deferrability, IReadOnlyList <string> referencedColumnNames, SqlColumnReferenceAction onDelete, SqlColumnReferenceAction onUpdate)
     : base(typeof(void))
 {
     this.OnDeleteAction        = onDelete;
     this.OnUpdateAction        = onUpdate;
     this.ReferencedTable       = referencedTable;
     this.Deferrability         = deferrability;
     this.ReferencedColumnNames = referencedColumnNames;
 }
 public SqlCreateIndexExpression(string indexName, SqlTableExpression table, bool unique, IndexType indexType, bool ifNotExist, IReadOnlyList <SqlIndexedColumnExpression> columns, IReadOnlyList <SqlIndexedColumnExpression> includedColumns, Expression where = null, bool?clustered = null)
     : base(indexName, columns, includedColumns)
 {
     this.Table      = table;
     this.Unique     = unique;
     this.IndexType  = indexType;
     this.IfNotExist = ifNotExist;
     this.Where      = where;
     this.Clustered  = clustered;
 }
Exemple #16
0
 public SqlCreateIndexExpression(string indexName, SqlTableExpression table, bool unique, bool lowercaseIndex, IndexType indexType, bool ifNotExist, IReadOnlyList <SqlIndexedColumnExpression> columns)
     : base(typeof(void))
 {
     this.IndexName      = indexName;
     this.Table          = table;
     this.Unique         = unique;
     this.LowercaseIndex = lowercaseIndex;
     this.IndexType      = indexType;
     this.IfNotExist     = ifNotExist;
     this.Columns        = columns;
 }
 public SqlCreateIndexExpression(string indexName, SqlTableExpression table, bool unique, bool lowercaseIndex, IndexType indexType, bool ifNotExist, IReadOnlyList<SqlIndexedColumnExpression> columns)
     : base(typeof(void))
 {
     this.IndexName = indexName;
     this.Table = table;
     this.Unique = unique;
     this.LowercaseIndex = lowercaseIndex;
     this.IndexType = indexType;
     this.IfNotExist = ifNotExist;
     this.Columns = columns;
 }
Exemple #18
0
        protected override Expression VisitTable(SqlTableExpression table)
        {
            SqlTableExpression current;

            if (!TryGetCurrent(table, out current))
            {
                return(table);
            }

            result = result && (current.Name == table.Name && current.Alias == table.Alias);

            return(table);
        }
 public SqlInsertIntoExpression(SqlTableExpression table, IEnumerable<string> columnNames, IEnumerable<string> returningAutoIncrementColumnNames, IEnumerable<Expression> valueExpressions)
     : this(table, columnNames.ToReadOnlyList(), returningAutoIncrementColumnNames.ToReadOnlyList(), valueExpressions.ToReadOnlyList())
 {
 }
 public SqlReferencesExpression(SqlTableExpression referencedTable, SqlColumnReferenceDeferrability deferrability, IEnumerable <string> referencedColumnNames, SqlColumnReferenceAction onDelete, SqlColumnReferenceAction onUpdate)
     : this(referencedTable, deferrability, referencedColumnNames.ToReadOnlyCollection(), onDelete, onUpdate)
 {
 }
        private IEnumerable<Expression> BuildCreateIndexExpressions(TypeDescriptor typeDescriptor)
        {
            var allIndexAttributes = typeDescriptor.PersistedProperties.Concat(typeDescriptor.RelatedProperties).SelectMany(c => c.IndexAttributes.Select(d => new Tuple<IndexAttribute, PropertyDescriptor>(d, c)));

            var indexAttributesByName = allIndexAttributes.GroupBy(c => c.Item1.IndexName ?? typeDescriptor.PersistedName + "_" + c.Item2.PersistedName + "_idx").Sorted((x, y) => String.CompareOrdinal(x.Key, y.Key));

            var table = new SqlTableExpression(typeDescriptor.PersistedName);

            foreach (var group in indexAttributesByName)
            {
                var indexName = group.Key;

                var propertyDescriptors = group.ToArray();

                yield return this.BuildIndexExpression(table, indexName, propertyDescriptors);
            }
        }
 public SqlCreateIndexExpression(string indexName, SqlTableExpression table, bool unique, bool lowercaseIndex, IndexType indexType, bool ifNotExist, IEnumerable<SqlIndexedColumnExpression> columns)
     : this(indexName, table, unique, lowercaseIndex, indexType, ifNotExist, columns.ToReadOnlyList())
 {
 }
Exemple #23
0
 public SqlCreateIndexExpression(string indexName, SqlTableExpression table, bool unique, bool lowercaseIndex, IndexType indexType, bool ifNotExist, IEnumerable <SqlIndexedColumnExpression> columns)
     : this(indexName, table, unique, lowercaseIndex, indexType, ifNotExist, columns.ToReadOnlyList())
 {
 }
        private Expression BuildIndexExpression(SqlTableExpression table, string indexName, Tuple<IndexAttribute, PropertyDescriptor>[] properties)
        {
            var unique = properties.Select(c => c.Item1).Any(c => c.Unique);
            var lowercaseIndex = properties.Select(c => c.Item1).Any(c => c.LowercaseIndex);
            var indexType = properties.Select(c => c.Item1.IndexType).FirstOrDefault(c => c != IndexType.Default);

            var sorted = properties.OrderBy(c => c.Item1.CompositeOrder, Comparer<int>.Default);

            var indexedColumns = new List<SqlIndexedColumnExpression>();

            foreach (var attributeAndProperty in sorted)
            {
                foreach (var columnInfo in QueryBinder.GetColumnInfos(this.model.TypeDescriptorProvider, attributeAndProperty.Item2))
                {
                    indexedColumns.Add(new SqlIndexedColumnExpression(new SqlColumnExpression(columnInfo.DefinitionProperty.PropertyType, null, columnInfo.ColumnName), attributeAndProperty.Item1.SortOrder, attributeAndProperty.Item1.LowercaseIndex));
                }
            }

            return new SqlCreateIndexExpression(indexName, table, unique, lowercaseIndex, indexType, false, indexedColumns);
        }
Exemple #25
0
 protected override Expression VisitTable(SqlTableExpression table)
 {
     return(base.VisitTable(table));
 }
 protected override Expression VisitTable(SqlTableExpression expression)
 {
     this.hashCode ^= expression.Name?.GetHashCode() ?? 0;
     this.hashCode ^= expression.Alias?.GetHashCode() ?? 0;
     return base.VisitTable(expression);
 }
		protected override Expression VisitTable(SqlTableExpression table)
		{
			results.Add(new Tuple<string, Type>(table.Alias, table.Type));

			return base.VisitTable(table);
		}
 public SqlCreateIndexExpression(string indexName, SqlTableExpression table, bool unique, IndexType indexType, bool ifNotExist, IEnumerable <SqlIndexedColumnExpression> columns, IEnumerable <SqlIndexedColumnExpression> includedColumns)
     : this(indexName, table, unique, indexType, ifNotExist, columns.ToReadOnlyCollection(), includedColumns.ToReadOnlyCollection())
 {
 }
Exemple #29
0
 protected override Expression VisitTable(SqlTableExpression expression)
 {
     this.hashCode ^= expression.Name?.GetHashCode() ?? 0;
     this.hashCode ^= expression.Alias?.GetHashCode() ?? 0;
     return(base.VisitTable(expression));
 }
		public SqlReferencesColumnExpression(SqlTableExpression referencedTable, SqlColumnReferenceDeferrability deferrability, IEnumerable<string> referencedColumnNames, SqlColumnReferenceAction onDelete, SqlColumnReferenceAction onUpdate)
			: this(referencedTable, deferrability, referencedColumnNames.ToReadOnlyCollection(), onDelete, onUpdate)
		{
		}
		public SqlCreateIndexExpression(string indexName, SqlTableExpression table, bool unique, bool lowercaseIndex, IndexType indexType, bool ifNotExist, IEnumerable<SqlIndexedColumnExpression> columns, IEnumerable<SqlColumnExpression> includedColumns, Expression where = null)
			: this(indexName, table, unique, lowercaseIndex, indexType, ifNotExist, columns.ToReadOnlyCollection(), includedColumns.ToReadOnlyCollection())
		{
		}
Exemple #32
0
 public SqlCreateTableExpression(SqlTableExpression table, bool ifNotExist, IEnumerable <SqlColumnDefinitionExpression> columnExpressions, IEnumerable <Expression> tableConstraintExpressions, IEnumerable <SqlTableOption> tableOptions = null)
     : this(table, ifNotExist, columnExpressions.ToReadOnlyCollection(), tableConstraintExpressions.ToReadOnlyCollection(), tableOptions?.ToReadOnlyCollection())
 {
 }
		protected virtual Expression VisitTable(SqlTableExpression table)
		{
			return table;
		}
        protected override Expression VisitTable(SqlTableExpression expression)
        {
            SqlTableExpression current;
            if (!TryGetCurrent(expression, out current))
            {
                return expression;
            }

            if (!(this.result &= object.Equals(current.Name, expression.Name)))
            {
                return expression;
            }

            if (!(this.result &= current.NodeType == expression.NodeType))
            {
                return expression;
            }

            if (!(this.result &= object.Equals(current.Alias, expression.Alias)))
            {
                return expression;
            }

            if (!(this.result &= current.Type == expression.Type))
            {
                return expression;
            }

            this.currentObject = current.Aliases;
            this.VisitObjectList(expression.Aliases);
            if (!this.result)
            {
                return expression;
            }

            this.currentObject = current;
            return expression;
        }
		public SqlCreateTableExpression(SqlTableExpression table, bool ifNotExist, IEnumerable<SqlColumnDefinitionExpression> columnExpressions, IEnumerable<Expression> tableConstraintExpressions)
			: this(table, ifNotExist, columnExpressions.ToReadOnlyList(), tableConstraintExpressions.ToReadOnlyList())
		{
		}
Exemple #36
0
 public SqlInsertIntoExpression(SqlTableExpression table, IEnumerable <string> columnNames, IEnumerable <string> returningAutoIncrementColumnNames, IEnumerable <Expression> valueExpressions)
     : this(table, columnNames.ToReadOnlyList(), returningAutoIncrementColumnNames.ToReadOnlyList(), valueExpressions.ToReadOnlyList())
 {
 }
Exemple #37
0
        protected override Expression VisitTable(SqlTableExpression expression)
        {
            this.WriteTableName(expression.Name);

            return expression;
        }
			protected override Expression VisitTable(SqlTableExpression table)
			{
				this.aliases.Add(table.Alias);

				return table;
			}
 protected virtual Expression VisitTable(SqlTableExpression table)
 {
     return(table);
 }