private ForeignKeyAssociationMappingConfiguration(ForeignKeyAssociationMappingConfiguration source)
        {
            DebugCheck.NotNull(source);

            _keyColumnNames.AddRange(source._keyColumnNames);
            _tableName = source._tableName;
        }
        public void Equals_returns_true_when_names_equal_and_no_schema_specified()
        {
            var databaseName1 = new DatabaseName("T");
            var databaseName2 = new DatabaseName("T");

            Assert.Equal(databaseName1, databaseName2);
        }
        public void Equals_returns_false_when_names_equal_and_schemas_not_equal()
        {
            var databaseName1 = new DatabaseName("T", "S1");
            var databaseName2 = new DatabaseName("T", "S2");

            Assert.NotEqual(databaseName1, databaseName2);
        }
        public static void SetTableName(this EntityType table, DatabaseName tableName)
        {
            DebugCheck.NotNull(table);
            DebugCheck.NotNull(tableName);

            table.GetMetadataProperties().SetAnnotation(TableNameAnnotation, tableName);
        }
        public static void SetTableName(this EntityType table, DatabaseName tableName)
        {
            DebugCheck.NotNull(table);
            DebugCheck.NotNull(tableName);

            table.Annotations.SetAnnotation(TableNameAnnotation, tableName);
        }
        /// <summary>
        ///     Configures the join table name and schema for the relationship.
        /// </summary>
        /// <param name="tableName"> Name of the table. </param>
        /// <param name="schemaName"> Schema of the table. </param>
        /// <returns> The same ManyToManyAssociationMappingConfiguration instance so that multiple calls can be chained. </returns>
        public ManyToManyAssociationMappingConfiguration ToTable(string tableName, string schemaName)
        {
            Check.NotEmpty(tableName, "tableName");

            _tableName = new DatabaseName(tableName, schemaName);

            return this;
        }
        private ManyToManyAssociationMappingConfiguration(ManyToManyAssociationMappingConfiguration source)
        {
            DebugCheck.NotNull(source);

            _leftKeyColumnNames.AddRange(source._leftKeyColumnNames);
            _rightKeyColumnNames.AddRange(source._rightKeyColumnNames);
            _tableName = source._tableName;
        }
        private ForeignKeyAssociationMappingConfiguration(ForeignKeyAssociationMappingConfiguration source)
        {
            DebugCheck.NotNull(source);

            _keyColumnNames.AddRange(source._keyColumnNames);
            _tableName = source._tableName;

            foreach (var annotation in source._annotations)
            {
                _annotations.Add(annotation);
            }
        }
        public static EntityType FindTableByName(this EdmModel database, DatabaseName tableName)
        {
            DebugCheck.NotNull(tableName);

            return database.EntityTypes.SingleOrDefault(
                t =>
                    {
                        var databaseName = t.GetTableName();
                        return databaseName != null
                                   ? databaseName.Equals(tableName)
                                   : string.Equals(t.Name, tableName.Name, StringComparison.Ordinal);
                    });
        }
        private ManyToManyAssociationMappingConfiguration(ManyToManyAssociationMappingConfiguration source)
        {
            DebugCheck.NotNull(source);

            _leftKeyColumnNames.AddRange(source._leftKeyColumnNames);
            _rightKeyColumnNames.AddRange(source._rightKeyColumnNames);
            _tableName = source._tableName;

            foreach (var annotation in source._annotations)
            {
                _annotations.Add(annotation);
            }
        }
Example #11
0
 public bool Equals(DatabaseName other)
 {
     if (object.ReferenceEquals((object)null, (object)other))
     {
         return(false);
     }
     if (object.ReferenceEquals((object)this, (object)other))
     {
         return(true);
     }
     if (string.Equals(other._name, this._name, StringComparison.Ordinal))
     {
         return(string.Equals(other._schema, this._schema, StringComparison.Ordinal));
     }
     return(false);
 }
        public static EntityType FindTableByName(this EdmModel database, DatabaseName tableName)
        {
            DebugCheck.NotNull(tableName);

            // PERF: this code written this way since it's part of a hotpath, consider its performance when refactoring. See codeplex #2298.
            var entityTypesList = database.EntityTypes as IList<EntityType> ?? database.EntityTypes.ToList();
            // ReSharper disable once LoopCanBeConvertedToQuery
            // ReSharper disable once ForCanBeConvertedToForeach
            for (var entityTypesIterator = 0; entityTypesIterator < entityTypesList.Count; ++entityTypesIterator)
            {
                var t = entityTypesList[entityTypesIterator];
                var databaseName = t.GetTableName();
                if (databaseName != null ? databaseName.Equals(tableName)
                    : string.Equals(t.Name, tableName.Name, StringComparison.Ordinal) && tableName.Schema == null)
                {
                    return t;
                }
            }

            return null;
        }
        public void ToString_returns_schema_and_table_name_when_schema_specified()
        {
            var databaseName = new DatabaseName("T", "S");

            Assert.Equal("S.T", databaseName.ToString());
        }
Example #14
0
        public bool Equals(DatabaseName other)
        {
            if (ReferenceEquals(null, other))
            {
                return false;
            }

            if (ReferenceEquals(this, other))
            {
                return true;
            }

            return string.Equals(other._name, _name, StringComparison.Ordinal)
                   && string.Equals(other._schema, _schema, StringComparison.Ordinal);
        }
Example #15
0
        public static DatabaseName ToDatabaseName(this string s)
        {
            DebugCheck.NotEmpty(s);

            return(DatabaseName.Parse(s));
        }