本文整理汇总了C#中System.Data.Entity.Edm.Db.DbTableMetadata类的典型用法代码示例。如果您正苦于以下问题:C# DbTableMetadata类的具体用法?C# DbTableMetadata怎么用?C# DbTableMetadata使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DbTableMetadata类属于System.Data.Entity.Edm.Db命名空间,在下文中一共展示了DbTableMetadata类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Apply_should_introduce_cascade_delete_on_constraints
public void Apply_should_introduce_cascade_delete_on_constraints()
{
var databaseMapping
= new DbDatabaseMapping()
.Initialize(new EdmModel().Initialize(), new DbDatabaseMetadata().Initialize());
var foreignKeyConstraint = new DbForeignKeyConstraintMetadata();
Assert.Equal(DbOperationAction.None, foreignKeyConstraint.DeleteAction);
var table = new DbTableMetadata();
table.ForeignKeyConstraints.Add(foreignKeyConstraint);
var associationType = new EdmAssociationType().Initialize();
associationType.SourceEnd.EndKind = EdmAssociationEndKind.Many;
associationType.SourceEnd.EntityType = new EdmEntityType();
associationType.TargetEnd.EndKind = EdmAssociationEndKind.Many;
associationType.TargetEnd.EntityType = new EdmEntityType();
var associationSetMapping = databaseMapping.AddAssociationSetMapping(new EdmAssociationSet { ElementType = associationType });
associationSetMapping.Table = table;
((IDbMappingConvention)new ManyToManyCascadeDeleteConvention()).Apply(databaseMapping);
Assert.Equal(DbOperationAction.Cascade, foreignKeyConstraint.DeleteAction);
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:26,代码来源:ManyToManyCascadeDeleteConventionTests.cs
示例2: WriteForeignKeyConstraintElement
internal void WriteForeignKeyConstraintElement(
DbTableMetadata dbTableMetadata, DbForeignKeyConstraintMetadata tableFKConstraint)
{
_xmlWriter.WriteStartElement(SsdlConstants.Element_Association);
_xmlWriter.WriteAttributeString(SsdlConstants.Attribute_Name, tableFKConstraint.Name);
var multiplicity = DetermineMultiplicity(dbTableMetadata, tableFKConstraint);
// If the FK is a Self Ref, then we need to append a suffix to the second role name
var roleNames = DbModelSsdlHelper.GetRoleNamePair(tableFKConstraint.PrincipalTable, dbTableMetadata);
// End
WriteAssociationEndElementHeader(roleNames[0], tableFKConstraint.PrincipalTable, multiplicity.Key);
if (tableFKConstraint.DeleteAction
!= DbOperationAction.None)
{
WriteOperationActionElement(SsdlConstants.Element_OnDelete, tableFKConstraint.DeleteAction);
}
WriteEndElement();
WriteAssociationEndElementHeader(roleNames[1], dbTableMetadata, multiplicity.Value);
WriteEndElement();
// ReferentialConstraint
WriteReferentialConstraintElementHeader();
WriteReferentialConstraintRoleElement(
SsdlConstants.Element_PrincipalRole, roleNames[0], tableFKConstraint.PrincipalTable.KeyColumns);
WriteReferentialConstraintRoleElement(
SsdlConstants.Element_DependentRole, roleNames[1], tableFKConstraint.DependentColumns);
WriteEndElement();
WriteEndElement();
}
开发者ID:junxy,项目名称:entityframework,代码行数:34,代码来源:DbModelSsdlSchemaWriter.cs
示例3: Configure_should_update_table_name_when_base_type_is_null
public void Configure_should_update_table_name_when_base_type_is_null()
{
var entityMappingConfiguration = new EntityMappingConfiguration
{
TableName = new DatabaseName("Foo")
};
var entityTypeMapping = new DbEntityTypeMapping
{
EntityType = new EdmEntityType()
};
var table = new DbTableMetadata
{
Name = "foo"
};
entityTypeMapping.TypeMappingFragments.Add(
new DbEntityTypeMappingFragment
{
Table = table
});
var databaseMapping =
new DbDatabaseMapping().Initialize(new EdmModel().Initialize(), new DbDatabaseMetadata().Initialize());
databaseMapping.Database.AddTable("foo");
entityMappingConfiguration.Configure(
databaseMapping, ProviderRegistry.Sql2008_ProviderManifest, entityTypeMapping.EntityType, ref entityTypeMapping, false, 0, 1);
Assert.Equal("Foo", table.GetTableName().Name);
}
开发者ID:junxy,项目名称:entityframework,代码行数:28,代码来源:EntityMappingConfigurationTests.cs
示例4: WriteAssociationSetEndElement
internal void WriteAssociationSetEndElement(DbTableMetadata end, string roleName)
{
_xmlWriter.WriteStartElement(SsdlConstants.Element_End);
_xmlWriter.WriteAttributeString(SsdlConstants.Attribute_Role, roleName);
_xmlWriter.WriteAttributeString(SsdlConstants.Attribute_EntitySet, end.Name);
_xmlWriter.WriteEndElement();
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:DbModelEntityContainerSsdlSchemaWriter.cs
示例5: IncludeColumn
public static DbTableColumnMetadata IncludeColumn(
DbTableMetadata table, DbTableColumnMetadata templateColumn, bool useExisting)
{
Contract.Requires(table != null);
Contract.Requires(templateColumn != null);
var existingColumn =
table.Columns.SingleOrDefault(c => string.Equals(c.Name, templateColumn.Name, StringComparison.Ordinal));
if (existingColumn == null)
{
templateColumn = templateColumn.Clone();
}
else if (!useExisting
&& !existingColumn.IsPrimaryKeyColumn)
{
templateColumn = templateColumn.Clone();
}
else
{
templateColumn = existingColumn;
}
return AddColumn(table, templateColumn);
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:25,代码来源:EntityMappingTransformer.cs
示例6: TableMapping
public TableMapping(DbTableMetadata table)
{
//Contract.Requires(table != null);
_table = table;
_entityTypes = new SortedEntityTypeIndex();
_columns = new List<ColumnMapping>();
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:7,代码来源:TableMapping.cs
示例7: GetRoleNamePair
/// <summary>
/// Return role name pair
/// </summary>
/// <param name="firstTable"> </param>
/// <param name="secondTable"> </param>
/// <returns> </returns>
internal static string[] GetRoleNamePair(DbTableMetadata firstTable, DbTableMetadata secondTable)
{
return new[]
{
firstTable.Name,
firstTable != secondTable ? secondTable.Name : secondTable.Name + selfRefRoleNameSuffix
};
}
开发者ID:junxy,项目名称:entityframework,代码行数:14,代码来源:DbModelSsdlHelper.cs
示例8: VisitKeyColumns
protected override void VisitKeyColumns(DbTableMetadata item, IEnumerable<DbTableColumnMetadata> keyColumns)
{
_schemaWriter.WriteDelaredKeyPropertiesElementHeader();
foreach (var keyColumn in keyColumns)
{
_schemaWriter.WriteDelaredKeyPropertyRefElement(keyColumn);
}
_schemaWriter.WriteEndElement();
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:9,代码来源:DbModelSsdlSerializationVisitor.cs
示例9: Apply_should_ignore_current_table
public void Apply_should_ignore_current_table()
{
var database = new DbDatabaseMetadata().Initialize();
var table = new DbTableMetadata { DatabaseIdentifier = "Customers" };
database.Schemas.Single().Tables.Add(table);
((IDbConvention<DbTableMetadata>)new PluralizingTableNameConvention()).Apply(table, database);
Assert.Equal("Customers", table.DatabaseIdentifier);
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:10,代码来源:PluralizingTableNameConventionTests.cs
示例10: AddColumn_should_set_properties_and_add_to_columns
public void AddColumn_should_set_properties_and_add_to_columns()
{
var table = new DbTableMetadata();
var tableColumn = table.AddColumn("Foo");
Assert.NotNull(tableColumn);
Assert.Equal("Foo", tableColumn.Name);
Assert.True(table.Columns.Contains(tableColumn));
}
开发者ID:junxy,项目名称:entityframework,代码行数:10,代码来源:DbTableMetadataExtensions.cs
示例11: Apply_should_order_by_annotation_if_given
public void Apply_should_order_by_annotation_if_given()
{
var table = new DbTableMetadata();
table.AddColumn("C").SetOrder(2);
table.AddColumn("Id").SetOrder(1);
((IDbConvention<DbTableMetadata>)new ColumnOrderingConvention()).Apply(table, new DbDatabaseMetadata());
Assert.Equal(2, table.Columns.Count);
Assert.Equal("Id", table.Columns.First().Name);
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:11,代码来源:ColumnOrderingConventionTests.cs
示例12: Apply_should_sort_unannotated_in_given_order
public void Apply_should_sort_unannotated_in_given_order()
{
var table = new DbTableMetadata();
table.AddColumn("C");
table.AddColumn("Id");
((IDbConvention<DbTableMetadata>)new ColumnOrderingConvention()).Apply(table, new DbDatabaseMetadata());
Assert.Equal(2, table.Columns.Count);
Assert.Equal("C", table.Columns.First().Name);
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:11,代码来源:ColumnOrderingConventionTests.cs
示例13: Apply_should_uniquify_names
public void Apply_should_uniquify_names()
{
var database = new DbDatabaseMetadata().Initialize();
var tableA = new DbTableMetadata { DatabaseIdentifier = "Customers" };
var tableB = new DbTableMetadata { DatabaseIdentifier = "Customer" };
database.Schemas.Single().Tables.Add(tableA);
database.Schemas.Single().Tables.Add(tableB);
((IDbConvention<DbTableMetadata>)new PluralizingTableNameConvention()).Apply(tableB, database);
Assert.Equal("Customers1", tableB.DatabaseIdentifier);
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:12,代码来源:PluralizingTableNameConventionTests.cs
示例14: Apply_should_ignored_configured_tables
public void Apply_should_ignored_configured_tables()
{
var database = new DbDatabaseMetadata().Initialize();
var table = new DbTableMetadata { DatabaseIdentifier = "Customer" };
table.SetTableName(new DatabaseName("Foo"));
database.Schemas.Single().Tables.Add(table);
((IDbConvention<DbTableMetadata>)new PluralizingTableNameConvention()).Apply(table, database);
Assert.Equal("Customer", table.DatabaseIdentifier);
Assert.Equal("Foo", table.GetTableName().Name);
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:12,代码来源:PluralizingTableNameConventionTests.cs
示例15: RemoveColumn
public static DbTableColumnMetadata RemoveColumn(DbTableMetadata table, DbTableColumnMetadata column)
{
Contract.Requires(table != null);
Contract.Requires(column != null);
if (!column.IsPrimaryKeyColumn)
{
table.Columns.Remove(column);
}
return column;
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:12,代码来源:EntityMappingTransformer.cs
示例16: WriteEntitySetElementHeader
internal void WriteEntitySetElementHeader(DbSchemaMetadata containingSchema, DbTableMetadata entitySet)
{
_xmlWriter.WriteStartElement(SsdlConstants.Element_EntitySet);
_xmlWriter.WriteAttributeString(SsdlConstants.Attribute_Name, entitySet.Name);
_xmlWriter.WriteAttributeString(
SsdlConstants.Attribute_EntityType, GetQualifiedTypeName(SsdlConstants.Value_Self, entitySet.Name));
if (containingSchema.DatabaseIdentifier != null)
{
_xmlWriter.WriteAttributeString(SsdlConstants.Attribute_Schema, containingSchema.DatabaseIdentifier);
}
if (entitySet.DatabaseIdentifier != null)
{
_xmlWriter.WriteAttributeString(SsdlConstants.Attribute_Table, entitySet.DatabaseIdentifier);
}
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:15,代码来源:DbModelEntityContainerSsdlSchemaWriter.cs
示例17: ValidateColumns
protected override void ValidateColumns(DbTableMetadata table)
{
var hasDuplicates
= table.Columns
.Select(c => c.GetOrder())
.Where(o => o != null)
.GroupBy(o => o)
.Where(g => g.Count() > 1)
.Any();
if (hasDuplicates)
{
throw Error.DuplicateConfiguredColumnOrder(table.DatabaseIdentifier);
}
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:15,代码来源:ColumnOrderingConventionStrict.cs
示例18: VisitDbTableMetadata
protected virtual void VisitDbTableMetadata(DbTableMetadata item)
{
VisitDbSchemaMetadataItem(item);
if (item != null)
{
if (item.HasColumns)
{
VisitKeyColumns(item, item.KeyColumns);
VisitColumns(item, item.Columns);
}
if (item.HasForeignKeyConstraints)
{
VisitForeignKeyConstraints(item, item.ForeignKeyConstraints);
}
}
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:16,代码来源:DbDatabaseVisitor.cs
示例19: AddTable
public static DbTableMetadata AddTable(this DbDatabaseMetadata database, string name)
{
//Contract.Requires(database != null);
//Contract.Requires(!string.IsNullOrWhiteSpace(name));
Contract.Assert(database.Schemas.Count == 1);
var schema = database.Schemas.Single();
var uniqueIdentifier = schema.Tables.UniquifyName(name);
var table = new DbTableMetadata
{
Name = uniqueIdentifier,
DatabaseIdentifier = uniqueIdentifier
};
schema.Tables.Add(table);
return table;
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:19,代码来源:DbDatabaseMetadataExtensions.cs
示例20: AddColumn
private static DbTableColumnMetadata AddColumn(DbTableMetadata table, DbTableColumnMetadata column)
{
Contract.Requires(table != null);
Contract.Requires(column != null);
if (!table.Columns.Contains(column))
{
var configuration = column.GetConfiguration() as PrimitivePropertyConfiguration;
if ((configuration == null)
|| string.IsNullOrWhiteSpace(configuration.ColumnName))
{
var preferredName = column.GetPreferredName() ?? column.Name;
column.SetUnpreferredUniqueName(column.Name);
column.Name = table.Columns.UniquifyName(preferredName);
}
table.Columns.Add(column);
}
return column;
}
开发者ID:WangWilliam,项目名称:EntityFramework5,代码行数:22,代码来源:EntityMappingTransformer.cs
注:本文中的System.Data.Entity.Edm.Db.DbTableMetadata类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论