本文整理汇总了C#中System.Data.Entity.ModelConfiguration.Configuration.Types.EntityTypeConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# EntityTypeConfiguration类的具体用法?C# EntityTypeConfiguration怎么用?C# EntityTypeConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EntityTypeConfiguration类属于System.Data.Entity.ModelConfiguration.Configuration.Types命名空间,在下文中一共展示了EntityTypeConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EntityTypeConfiguration
private EntityTypeConfiguration(EntityTypeConfiguration source)
: base(source)
{
DebugCheck.NotNull(source);
_keyProperties.AddRange(source._keyProperties);
source._navigationPropertyConfigurations.Each(
c => _navigationPropertyConfigurations.Add(c.Key, c.Value.Clone()));
source._entitySubTypesMappingConfigurations.Each(
c => _entitySubTypesMappingConfigurations.Add(c.Key, c.Value.Clone()));
_entityMappingConfigurations.AddRange(
source._entityMappingConfigurations.Except(source._nonCloneableMappings).Select(e => e.Clone()));
_isKeyConfigured = source._isKeyConfigured;
_entitySetName = source._entitySetName;
if (source._modificationFunctionsConfiguration != null)
{
_modificationFunctionsConfiguration = source._modificationFunctionsConfiguration.Clone();
}
IsReplaceable = source.IsReplaceable;
IsTableNameConfigured = source.IsTableNameConfigured;
IsExplicitEntity = source.IsExplicitEntity;
}
示例2: Map_TDerived_should_add_mapping_configuration_to_self_if_tderived_is_same_as_tentity
public void Map_TDerived_should_add_mapping_configuration_to_self_if_tderived_is_same_as_tentity()
{
var entityConfiguration = new EntityTypeConfiguration<A>();
entityConfiguration.Map<A>(m => m.ToTable("A"));
Assert.Equal("A", ((EntityTypeConfiguration)entityConfiguration.Configuration).GetTableName().Name);
}
示例3: Configure_should_configure_modification_functions
public void Configure_should_configure_modification_functions()
{
var model = new EdmModel(DataSpace.CSpace);
var entityType = model.AddEntityType("E");
entityType.GetMetadataProperties().SetClrType(typeof(object));
model.AddEntitySet("ESet", entityType);
var modificationFunctionsConfigurationMock = new Mock<ModificationStoredProceduresConfiguration>();
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
entityTypeConfiguration.MapToStoredProcedures(modificationFunctionsConfigurationMock.Object, true);
entityType.SetConfiguration(entityTypeConfiguration);
var databaseMapping
= new DatabaseMappingGenerator(ProviderRegistry.Sql2008_ProviderInfo, ProviderRegistry.Sql2008_ProviderManifest).Generate(model);
entityTypeConfiguration.Configure(entityType, databaseMapping, ProviderRegistry.Sql2008_ProviderManifest);
modificationFunctionsConfigurationMock
.Verify(
m => m.Configure(
It.IsAny<EntityTypeModificationFunctionMapping>(), It.IsAny<DbProviderManifest>()),
Times.Once());
}
示例4: Configuration_should_return_internal_configuration
public void Configuration_should_return_internal_configuration()
{
var entityConfiguration = new EntityTypeConfiguration<object>();
Assert.NotNull(entityConfiguration.Configuration);
Assert.Equal(typeof(EntityTypeConfiguration), entityConfiguration.Configuration.GetType());
}
示例5: Add
internal virtual void Add(EntityTypeConfiguration entityTypeConfiguration)
{
DebugCheck.NotNull(entityTypeConfiguration);
EntityTypeConfiguration existingConfiguration;
if ((_entityConfigurations.TryGetValue(entityTypeConfiguration.ClrType, out existingConfiguration)
&& !existingConfiguration.IsReplaceable)
|| _complexTypeConfigurations.ContainsKey(entityTypeConfiguration.ClrType))
{
throw Error.DuplicateStructuralTypeConfiguration(entityTypeConfiguration.ClrType);
}
if (existingConfiguration != null
&& existingConfiguration.IsReplaceable)
{
_entityConfigurations.Remove(existingConfiguration.ClrType);
entityTypeConfiguration.ReplaceFrom(existingConfiguration);
}
else
{
entityTypeConfiguration.IsReplaceable = false;
}
_entityConfigurations.Add(entityTypeConfiguration.ClrType, entityTypeConfiguration);
}
示例6: Configure
internal override void Configure(
EdmAssociationType associationType, EdmAssociationEnd dependentEnd,
EntityTypeConfiguration entityTypeConfiguration)
{
//Contract.Requires(associationType != null);
//Contract.Requires(dependentEnd != null);
//Contract.Requires(entityTypeConfiguration != null);
}
示例7: HasKey_should_throw_when_invalid_key_expression
public void HasKey_should_throw_when_invalid_key_expression()
{
var entityConfiguration = new EntityTypeConfiguration<object>();
Assert.Equal(
Strings.InvalidPropertiesExpression("o => o.ToString()"),
Assert.Throws<InvalidOperationException>(() => entityConfiguration.HasKey(o => o.ToString())).Message);
}
示例8: Apply_should_set_table_name
public void Apply_should_set_table_name()
{
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
new TableAttributeConvention.TableAttributeConventionImpl()
.Apply(new MockType(), entityTypeConfiguration, new TableAttribute("Foo"));
Assert.Equal("Foo", entityTypeConfiguration.GetTableName().Name);
}
示例9: MapToStoredProcedures_should_call_method_on_internal_configuration
public void MapToStoredProcedures_should_call_method_on_internal_configuration()
{
var mockEntityTypeConfiguration = new Mock<EntityTypeConfiguration>(typeof(Fixture));
var entityConfiguration = new EntityTypeConfiguration<Fixture>(mockEntityTypeConfiguration.Object);
entityConfiguration.MapToStoredProcedures();
mockEntityTypeConfiguration.Verify(e => e.MapToStoredProcedures());
}
示例10: Configure_should_set_configuration
public void Configure_should_set_configuration()
{
var entityType = new EntityType("E", "N", DataSpace.CSpace);
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
entityTypeConfiguration.Configure(entityType, new EdmModel(DataSpace.CSpace));
Assert.Same(entityTypeConfiguration, entityType.GetConfiguration());
}
示例11: HasKey_should_add_key_properties
public void HasKey_should_add_key_properties()
{
var mockEntityTypeConfiguration = new Mock<EntityTypeConfiguration>(typeof(Fixture));
var entityConfiguration = new EntityTypeConfiguration<Fixture>(mockEntityTypeConfiguration.Object);
entityConfiguration.HasKey(f => f.Id);
mockEntityTypeConfiguration.Verify(e => e.Key(new[] { typeof(Fixture).GetProperty("Id") }));
}
示例12: Map_TDerived_should_throw_for_repeat_configuration_of_derived_type
public void Map_TDerived_should_throw_for_repeat_configuration_of_derived_type()
{
var entityConfiguration = new EntityTypeConfiguration<A>();
Assert.Equal(Strings.InvalidChainedMappingSyntax("B"), Assert.Throws<InvalidOperationException>(() => entityConfiguration
.Map<A>(m => m.ToTable("A"))
.Map<B>(mb => mb.ToTable("B"))
.Map<C>(mc => mc.ToTable("C"))
.Map<B>(mb2 => mb2.ToTable("B"))).Message);
}
示例13: Can_pass_function_mapping_configuration_to_map_to_functions
public void Can_pass_function_mapping_configuration_to_map_to_functions()
{
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
Assert.Null(entityTypeConfiguration.ModificationStoredProceduresConfiguration);
entityTypeConfiguration.MapToStoredProcedures(new ModificationStoredProceduresConfiguration(), true);
Assert.NotNull(entityTypeConfiguration.ModificationStoredProceduresConfiguration);
}
示例14: Configure
internal override void Configure(
AssociationType associationType, AssociationEndMember dependentEnd,
EntityTypeConfiguration entityTypeConfiguration)
{
DebugCheck.NotNull(associationType);
DebugCheck.NotNull(dependentEnd);
DebugCheck.NotNull(entityTypeConfiguration);
associationType.MarkIndependent();
}
示例15: Apply_should_ignore_property
public void Apply_should_ignore_property()
{
var mockPropertyInfo = new MockPropertyInfo();
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
new NotMappedPropertyAttributeConvention.NotMappedPropertyAttributeConventionImpl()
.Apply(mockPropertyInfo, entityTypeConfiguration, new NotMappedAttribute());
Assert.True(entityTypeConfiguration.IgnoredProperties.Contains(mockPropertyInfo));
}