本文整理汇总了C#中EntityTypeConfiguration类的典型用法代码示例。如果您正苦于以下问题:C# EntityTypeConfiguration类的具体用法?C# EntityTypeConfiguration怎么用?C# EntityTypeConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityTypeConfiguration类属于命名空间,在下文中一共展示了EntityTypeConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
/// <summary>
/// Figures out the key properties and marks them as Keys in the EDM model.
/// </summary>
/// <param name="entity">The entity type being configured.</param>
/// <param name="model">The <see cref="ODataModelBuilder"/>.</param>
public override void Apply(EntityTypeConfiguration entity, ODataConventionModelBuilder model)
{
if (entity == null)
{
throw Error.ArgumentNull("entity");
}
// Suppress the EntityKeyConvention if there is any key in EntityTypeConfiguration.
if (entity.Keys.Any() || entity.EnumKeys.Any())
{
return;
}
// Suppress the EntityKeyConvention if base type has any key.
if (entity.BaseType != null && entity.BaseType.Keys().Any())
{
return;
}
PropertyConfiguration key = GetKeyProperty(entity);
if (key != null)
{
entity.HasKey(key.PropertyInfo);
}
}
示例2: NhsContext
public NhsContext(EntityTypeConfiguration<Person> personTypeConfiguration,
EntityTypeConfiguration<Colour> colourTypeConfiguration)
: base("name=NhsContext")
{
_personTypeConfiguration = personTypeConfiguration;
_colourTypeConfiguration = colourTypeConfiguration;
}
示例3: RegTo
public void RegTo(ConfigurationRegistrar confRegistrar)
{
var r = new EntityTypeConfiguration<UserInfo>();
r.ToTable("UserInfo");
r.HasKey(p => p.AutoId);
confRegistrar.Add<UserInfo>(r);
}
示例4: Apply
public override void Apply(EntityTypeConfiguration entity, ODataModelBuilder model)
{
if (entity.IsAbstract == null)
{
entity.IsAbstract = entity.ClrType.IsAbstract;
}
}
示例5: Can_get_and_set_table_name
public void Can_get_and_set_table_name()
{
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
entityTypeConfiguration.ToTable("Foo");
Assert.Equal("Foo", entityTypeConfiguration.GetTableName().Name);
}
示例6: GetDefaultNavigationSource
private static NavigationSourceConfiguration GetDefaultNavigationSource(EntityTypeConfiguration targetEntityType,
ODataModelBuilder model, bool isSingleton)
{
if (targetEntityType == null)
{
return null;
}
NavigationSourceConfiguration[] matchingNavigationSources = null;
if (isSingleton)
{
matchingNavigationSources = model.Singletons.Where(e => e.EntityType == targetEntityType).ToArray();
}
else
{
matchingNavigationSources = model.EntitySets.Where(e => e.EntityType == targetEntityType).ToArray();
}
if (matchingNavigationSources.Length > 1)
{
return null;
}
else if (matchingNavigationSources.Length == 1)
{
return matchingNavigationSources[0];
}
else
{
// default navigation source is the same as the default navigation source for the base type.
return GetDefaultNavigationSource(targetEntityType.BaseType as EntityTypeConfiguration,
model, isSingleton);
}
}
示例7: ExpressionTranslator
/// <summary>
/// Constructor.
/// </summary>
/// <param name="nameChanges"></param>
internal ExpressionTranslator(EntityTypeConfiguration configuration)
{
//_nameChanges = nameChanges;
_configuration = configuration;
_nameChanges = configuration.KeyMappings;
_constantEvaluator = new ExpressionEvaluator();
}
开发者ID:s-innovations,项目名称:azure-table-storage-repository-pattern,代码行数:12,代码来源:ExpressionTranslator.cs
示例8: MapApiDataSource
/// <summary>Defines the mapping information for the entity 'ApiDataSource'</summary>
/// <param name="config">The configuration to modify.</param>
protected virtual void MapApiDataSource(EntityTypeConfiguration<ApiDataSource> config)
{
config.ToTable("ApiDataSource");
config.HasKey(t => t.Id);
config.Property(t => t.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
config.Property(t => t.SourceName).HasMaxLength(50).IsRequired();
config.Property(t => t.SourceBaseUrl).HasMaxLength(200);
}
示例9: Configure_should_throw_when_property_not_found
public void Configure_should_throw_when_property_not_found()
{
var entityType = new EdmEntityType { Name = "E" };
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
var mockPropertyConfiguration = new Mock<PrimitivePropertyConfiguration>();
entityTypeConfiguration.Property(new PropertyPath(new MockPropertyInfo()), () => mockPropertyConfiguration.Object);
Assert.Equal(Strings.PropertyNotFound(("P"), "E"), Assert.Throws<InvalidOperationException>(() => entityTypeConfiguration.Configure(entityType, new EdmModel())).Message);
}
示例10: Add_entity_configuration_should_add_to_model_configuration
public void Add_entity_configuration_should_add_to_model_configuration()
{
var modelConfiguration = new ModelConfiguration();
var entityConfiguration = new EntityTypeConfiguration<object>();
new ConfigurationRegistrar(modelConfiguration).Add(entityConfiguration);
Assert.Same(entityConfiguration.Configuration, modelConfiguration.Entity(typeof(object)));
}
示例11: Configure_should_set_configuration
public void Configure_should_set_configuration()
{
var entityType = new EdmEntityType { Name = "E" };
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
entityTypeConfiguration.Configure(entityType, new EdmModel());
Assert.Same(entityTypeConfiguration, entityType.GetConfiguration());
}
示例12: GetTableName_returns_current_TableName
public void GetTableName_returns_current_TableName()
{
var entityTypeConfiguration = new EntityTypeConfiguration(typeof(object));
Assert.Equal(null, entityTypeConfiguration.GetTableName());
entityTypeConfiguration.ToTable("Foo");
Assert.Equal("Foo", entityTypeConfiguration.GetTableName().Name);
}
示例13: Define
internal static void Define(EntityTypeConfiguration<Domain.Transaction> config)
{
config.HasOptional(p => p.CreditedUser)
.WithMany(r => r.Credits)
.HasForeignKey(fk => fk.CreditedUserId);
config.HasOptional(p => p.DebitedUser)
.WithMany(r => r.Debits)
.HasForeignKey(fk => fk.DebitedUserId);
config.Property(p => p.Amount).HasPrecision(19, 4);
}
示例14: Define
internal static void Define(EntityTypeConfiguration<Domain.ItemInstance> config)
{
config.HasRequired(r => r.Item)
.WithMany(r => r.OwnedBy)
.HasForeignKey(fk => fk.ItemId)
.WillCascadeOnDelete(false);
config.HasRequired(r => r.Owner)
.WithMany(r => r.Items)
.HasForeignKey(fk => fk.OwnerId)
.WillCascadeOnDelete(false);
}
示例15: MapMovieNotFound
/// <summary>Defines the mapping information for the entity 'MovieNotFound'</summary>
/// <param name="config">The configuration to modify.</param>
protected virtual void MapMovieNotFound(EntityTypeConfiguration<MovieNotFound> config)
{
config.ToTable("MovieNotFound");
config.HasKey(t => new { t.ItemId, t.ItemSource });
config.Property(t => t.ItemId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
config.Property(t => t.ItemSource).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
config.Property(t => t.RowId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity).IsRequired();
config.Property(t => t.ItemSearchTitle).HasMaxLength(100);
config.Property(t => t.ItemSearchYear);
config.Property(t => t.AddedOn);
config.Property(t => t.ChangedOn);
}