本文整理汇总了C#中InternalModelBuilder.IsIgnored方法的典型用法代码示例。如果您正苦于以下问题:C# InternalModelBuilder.IsIgnored方法的具体用法?C# InternalModelBuilder.IsIgnored怎么用?C# InternalModelBuilder.IsIgnored使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InternalModelBuilder
的用法示例。
在下文中一共展示了InternalModelBuilder.IsIgnored方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Apply
public virtual InternalModelBuilder Apply(InternalModelBuilder modelBuilder)
{
Check.NotNull(modelBuilder, nameof(modelBuilder));
foreach (var entityType in modelBuilder.Metadata.GetEntityTypes())
{
var unmappedProperty = entityType.GetProperties().FirstOrDefault(p => !IsMappedPrimitiveProperty(((IProperty)p).ClrType));
if (unmappedProperty != null)
{
throw new InvalidOperationException(CoreStrings.PropertyNotMapped(unmappedProperty.Name, entityType.Name));
}
if (entityType.HasClrType())
{
var clrProperties = new HashSet<string>();
clrProperties.UnionWith(entityType.ClrType.GetRuntimeProperties()
.Where(pi => pi.IsCandidateProperty())
.Select(pi => pi.Name));
clrProperties.ExceptWith(entityType.GetProperties().Select(p => p.Name));
clrProperties.ExceptWith(entityType.GetNavigations().Select(p => p.Name));
var entityTypeBuilder = modelBuilder.Entity(entityType.ClrType, ConfigurationSource.Convention);
clrProperties.RemoveWhere(p => entityTypeBuilder.IsIgnored(p, ConfigurationSource.Convention));
if (clrProperties.Count > 0)
{
foreach (var clrProperty in clrProperties)
{
var actualProperty = entityType.ClrType.GetRuntimeProperty(clrProperty);
var targetType = FindCandidateNavigationPropertyType(actualProperty);
if (targetType != null)
{
if (!modelBuilder.IsIgnored(targetType.DisplayName(), ConfigurationSource.Convention))
{
throw new InvalidOperationException(CoreStrings.NavigationNotAdded(actualProperty.Name, entityType.Name));
}
}
else
{
throw new InvalidOperationException(CoreStrings.PropertyNotAdded(actualProperty.Name, entityType.Name));
}
}
}
}
}
return modelBuilder;
}