/// <summary> /// Binds the mixins to the entity through change tracking. /// </summary> /// <param name="entry">The entity entry.</param> /// <param name="entityType">The entity type.</param> /// <param name="entity">The entity instance.</param> private void BindMixins(InternalEntityEntry entry, IEntityType entityType, object entity) { var mixinHost = entity as ISupportMixins; if (mixinHost != null) { var mixinTypes = entityType .Annotations .Where(a => a.Name == "MixinType") .Select(a => (Type)a.Value) .Distinct() .ToArray(); foreach (var mixinType in mixinTypes) { // Create the mixin. var mixin = (Mixin)Activator.CreateInstance(mixinType); // Set the resolver. mixin.SetPropertyEntryResolver(p => new PropertyEntry(entry, p)); // Assign to the host entity. mixinHost.AddMixin(mixin); } } }
/// <summary> /// Selects the appropriate value generator for a given property. /// </summary> /// <param name="property"> The property to get the value generator for. </param> /// <param name="entityType"> /// The entity type that the value generator will be used for. When called on inherited properties on derived entity types, /// this entity type may be different from the declared entity type on <paramref name="property" /> /// </param> /// <returns> The value generator to be used. </returns> public virtual ValueGenerator Select(IProperty property, IEntityType entityType) { Check.NotNull(property, nameof(property)); Check.NotNull(entityType, nameof(entityType)); return Cache.GetOrAdd(property, entityType, Create); }
public override EntityKey Create( IEntityType entityType, IReadOnlyList<IProperty> properties, IValueReader valueReader) { var components = new object[properties.Count]; for (var i = 0; i < properties.Count; i++) { var index = properties[i].Index; if (valueReader.IsNull(index)) { return EntityKey.InvalidEntityKey; } var value = _boxedValueReaders[i].ReadValue(valueReader, index); if (Equals(value, _sentinels[i])) { return EntityKey.InvalidEntityKey; } components[i] = value; } return new CompositeEntityKey(entityType, components); }
public virtual InternalEntityEntry StartTracking( IEntityType entityType, EntityKey entityKey, object entity, ValueBuffer valueBuffer) { if (entityKey == EntityKey.InvalidEntityKey) { throw new InvalidOperationException(Strings.InvalidPrimaryKey(entityType.DisplayName())); } var existingEntry = TryGetEntry(entityKey); if (existingEntry != null) { if (existingEntry.Entity != entity) { throw new InvalidOperationException(Strings.IdentityConflict(entityType.DisplayName())); } return existingEntry; } var newEntry = _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity, valueBuffer)); _identityMap.Add(entityKey, newEntry); _entityReferenceMap[entity] = newEntry; newEntry.SetEntityState(EntityState.Unchanged); return newEntry; }
public virtual InternalEntityEntry StartTracking(IEntityType entityType, object entity, IValueReader valueReader) { // TODO: Perf: Pre-compute this for speed var keyProperties = entityType.GetPrimaryKey().Properties; var keyValue = _keyFactorySource.GetKeyFactory(keyProperties).Create(entityType, keyProperties, valueReader); if (keyValue == EntityKey.InvalidEntityKey) { throw new InvalidOperationException(Strings.InvalidPrimaryKey(entityType.DisplayName())); } var existingEntry = TryGetEntry(keyValue); if (existingEntry != null) { if (existingEntry.Entity != entity) { throw new InvalidOperationException(Strings.IdentityConflict(entityType.DisplayName())); } return existingEntry; } var newEntry = _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity, valueReader)); _identityMap.Add(keyValue, newEntry); _entityReferenceMap[entity] = newEntry; newEntry.SetEntityState(EntityState.Unchanged); return newEntry; }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public virtual bool IsSingleQueryMode(IEntityType entityType) { if (_singleQueryMode == false) { // Once we are out of SQM we are always out. return false; } // If we already checked for self-refs then don't check again. if (_singleQueryModeEntityType == entityType) { return true; } // Drop out if SQM for change of entity type or self-refs since query may not fix them up. if (_singleQueryModeEntityType != null || entityType.GetNavigations().Any(n => entityType.IsSameHierarchy(n.GetTargetType()))) { _singleQueryMode = false; return false; } _singleQueryModeEntityType = entityType; return true; }
/// <inheritdoc /> public override InternalEntityEntry Create(IStateManager stateManager, IEntityType entityType, object entity, ValueBuffer valueBuffer) { var entry = base.Create(stateManager, entityType, entity, valueBuffer); BindMixins(entry, entityType, entity); return entry; }
public override EntityKey Create(IEntityType entityType, IReadOnlyList<IProperty> properties, IPropertyBagEntry propertyBagEntry) { Check.NotNull(entityType, "entityType"); Check.NotNull(properties, "properties"); Check.NotNull(propertyBagEntry, "propertyBagEntry"); return Create(entityType, properties.Select(p => propertyBagEntry[p]).ToArray()); }
public CompositeEntityKey([NotNull] IEntityType entityType, [NotNull] object[] keyValueParts) { Check.NotNull(entityType, "entityType"); Check.NotNull(keyValueParts, "keyValueParts"); _entityType = entityType; _keyValueParts = keyValueParts; }
/// <summary> /// Gets the existing value generator from the cache, or creates a new one if one is not present in /// the cache. /// </summary> /// <param name="property"> The property to get the value generator for. </param> /// <param name="entityType"> /// The entity type that the value generator will be used for. When called on inherited properties on derived entity types, /// this entity type may be different from the declared entity type on <paramref name="property" /> /// </param> /// <param name="factory"> Factory to create a new value generator if one is not present in the cache. </param> /// <returns> The existing or newly created value generator. </returns> public virtual ValueGenerator GetOrAdd( IProperty property, IEntityType entityType, Func<IProperty, IEntityType, ValueGenerator> factory) { Check.NotNull(property, nameof(property)); Check.NotNull(factory, nameof(factory)); return _cache.GetOrAdd(new CacheKey(property, entityType, factory), ck => ck.Factory(ck.Property, ck.EntityType)); }
public virtual InternalEntityEntry CreateNewEntry(IEntityType entityType) { // TODO: Consider entities without parameterless constructor--use o/c mapping info? // Issue #240 var entity = entityType.HasClrType() ? Activator.CreateInstance(entityType.ClrType) : null; return _subscriber.SnapshotAndSubscribe(_factory.Create(this, entityType, entity), null); }
public virtual Expression CreateMaterializeExpression( IEntityType entityType, Expression valueReaderExpression, int[] indexMap = null) { Check.NotNull(entityType, nameof(entityType)); Check.NotNull(valueReaderExpression, nameof(valueReaderExpression)); var materializer = entityType as IEntityMaterializer; if (materializer != null) { return Expression.Call( Expression.Constant(materializer), ((Func<IValueReader, object>)materializer.CreateEntity).GetMethodInfo(), valueReaderExpression); } if (!entityType.HasClrType()) { throw new InvalidOperationException(Strings.NoClrType(entityType.Name)); } if (entityType.IsAbstract) { throw new InvalidOperationException(Strings.CannotMaterializeAbstractType(entityType)); } var instanceVariable = Expression.Variable(entityType.ClrType, "instance"); var blockExpressions = new List<Expression> { Expression.Assign( instanceVariable, Expression.New(entityType.ClrType.GetDeclaredConstructor(null))) }; blockExpressions.AddRange( from mapping in _memberMapper.MapPropertiesToMembers(entityType) let propertyInfo = mapping.Item2 as PropertyInfo let targetMember = propertyInfo != null ? Expression.Property(instanceVariable, propertyInfo) : Expression.Field(instanceVariable, (FieldInfo)mapping.Item2) select Expression.Assign( targetMember, CreateReadValueExpression( valueReaderExpression, targetMember.Type, indexMap?[mapping.Item1.Index] ?? mapping.Item1.Index))); blockExpressions.Add(instanceVariable); return Expression.Block(new[] { instanceVariable }, blockExpressions); }
public override ValueGenerator Select(IProperty property, IEntityType entityType) { Check.NotNull(property, nameof(property)); Check.NotNull(entityType, nameof(entityType)); return property.SqlServer().IdentityStrategy == SqlServerIdentityStrategy.SequenceHiLo ? _sequenceFactory.Create(property, Cache.GetOrAddSequenceState(property), _connection) : Cache.GetOrAdd(property, entityType, Create); }
public override ValueGenerator Create(IProperty property, IEntityType entityType) { Check.NotNull(property, nameof(property)); Check.NotNull(entityType, nameof(entityType)); return property.ClrType.IsInteger() ? _inMemoryFactory.Create(property) : base.Create(property, entityType); }
public override EntityKey Create(IEntityType entityType, IReadOnlyList<IProperty> properties, IValueReader valueReader) { Check.NotNull(entityType, "entityType"); Check.NotNull(properties, "properties"); Check.NotNull(valueReader, "valueReader"); // TODO: Consider using strongly typed ReadValue instead of always object return Create(entityType, properties.Select(p => valueReader.ReadValue<object>(p.Index)).ToArray()); }
public override ValueGenerator Create(IProperty property, IEntityType entityType) { Check.NotNull(property, nameof(property)); Check.NotNull(entityType, nameof(entityType)); return property.ClrType == typeof(Guid) ? _sequentialGuidFactory.Create(property) : base.Create(property, entityType); }
public AggregateDescriptor(IEntityType aggregateRoot, IEntityType[] aggregateEntities) { if (aggregateEntities == null || aggregateEntities.Length == 0) { throw new ArgumentNullException("aggregateEntities"); } _aggregateRoot = aggregateRoot; _aggregateEntities = aggregateEntities; }
public TestStateEntry WithType(string name) { var e = new EntityType(name); e.AddProperty("PartitionKey", typeof(string), true, false); e.AddProperty("RowKey", typeof(string), true, false); e.AddProperty("ETag", typeof(string), true, false); e.AddProperty("Timestamp", typeof(DateTime), true, false); _entityType = e; return this; }
private Func<IValueReader, object> BuildDelegate(IEntityType entityType) { var memberMappings = _memberMapper.MapPropertiesToMembers(entityType); var clrType = entityType.Type; var readerParameter = Expression.Parameter(typeof(IValueReader), "valueReader"); var instanceVariable = Expression.Variable(clrType, "instance"); var blockExpressions = new List<Expression> { Expression.Assign(instanceVariable, Expression.New(clrType.GetDeclaredConstructor(null))) }; foreach (var mapping in memberMappings) { var propertyInfo = mapping.Item2 as PropertyInfo; var fieldInfo = mapping.Item2 as FieldInfo; var targetType = propertyInfo != null ? propertyInfo.PropertyType : fieldInfo.FieldType; var indexExpression = Expression.Constant(mapping.Item1.Index); Expression callReaderExpression = Expression.Call( readerParameter, _readValue.MakeGenericMethod(targetType), indexExpression); if (targetType.IsNullableType()) { callReaderExpression = Expression.Condition( Expression.Call(readerParameter, _isNull, indexExpression), Expression.Constant(null, targetType), callReaderExpression); } if (propertyInfo != null) { blockExpressions.Add( Expression.Assign(Expression.Property(instanceVariable, propertyInfo), callReaderExpression)); } else { blockExpressions.Add( Expression.Assign(Expression.Field(instanceVariable, fieldInfo), callReaderExpression)); } } blockExpressions.Add(instanceVariable); return Expression.Lambda<Func<IValueReader, object>>(Expression.Block(new[] { instanceVariable }, blockExpressions), readerParameter).Compile(); }
private InternalEntityEntry NewInternalEntityEntry(IStateManager stateManager, IEntityType entityType, object entity, IValueReader valueReader) { if (!entityType.HasClrType()) { return new InternalShadowEntityEntry(stateManager, entityType, _metadataServices, valueReader); } return entityType.ShadowPropertyCount() > 0 ? (InternalEntityEntry)new InternalMixedEntityEntry(stateManager, entityType, _metadataServices, entity, valueReader) : new InternalClrEntityEntry(stateManager, entityType, _metadataServices, entity); }
protected StateEntry( [NotNull] DbContextConfiguration configuration, [NotNull] IEntityType entityType) { Check.NotNull(configuration, "configuration"); Check.NotNull(entityType, "entityType"); _configuration = configuration; _entityType = entityType; _stateData = new StateData(entityType.Properties.Count); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public override ValueGenerator Create(IProperty property, IEntityType entityType) { Check.NotNull(property, nameof(property)); Check.NotNull(entityType, nameof(entityType)); return property.ClrType.UnwrapNullableType() == typeof(Guid) ? property.ValueGenerated == ValueGenerated.Never || property.SqlServer().DefaultValueSql != null ? (ValueGenerator)new TemporaryGuidValueGenerator() : new SequentialGuidValueGenerator() : base.Create(property, entityType); }
private static IEnumerable<IEntityType> GetDerivedTypes(IModel model, IEntityType entityType) { foreach (var et1 in GetDirectlyDerivedTypes(model, entityType)) { yield return et1; foreach (var et2 in GetDerivedTypes(model, et1)) { yield return et2; } } }
public static EntityTypeSurrogate To(IEntityType value) { if (value == null) { return null; } var surrogate = SurrogateFactory<EntityTypeSurrogate>.Factory(); surrogate.Id = value.Id; return surrogate; }
public override ValueGenerator Select(IProperty property, IEntityType entityType) { Check.NotNull(property, nameof(property)); Check.NotNull(entityType, nameof(entityType)); var strategy = property.SqlServer().ValueGenerationStrategy; return property.ClrType.IsInteger() && strategy == SqlServerValueGenerationStrategy.Sequence ? _sequenceFactory.Create(property, Cache.GetOrAddSequenceState(property), _connection) : Cache.GetOrAdd(property, entityType, Create); }
public override InternalEntityEntry StartTrackingFromQuery(IEntityType entityType, object entity, ValueBuffer valueBuffer) { InTracking = true; try { return base.StartTrackingFromQuery(entityType, entity, valueBuffer); } finally { InTracking = false; } }
public override ValueGenerator Create(IProperty property, IEntityType entityType) { Check.NotNull(property, nameof(property)); Check.NotNull(entityType, nameof(entityType)); return property.ClrType.UnwrapNullableType() == typeof(Guid) ? (property.ValueGenerated == ValueGenerated.Never || property.SqlServer().GeneratedValueSql != null) ? _tempraryGuidFactory.Create(property) : _sequentialGuidFactory.Create(property) : base.Create(property, entityType); }
private static IEnumerable<IEntityType> GetDerivedTypes(IModel model, IEntityType entityType) { foreach (var et1 in model.EntityTypes .Where(et1 => et1.BaseType == entityType)) { yield return et1; foreach (var et2 in GetDerivedTypes(model, et1)) { yield return et2; } } }
public virtual EntityTrackingInfo Create( QueryCompilationContext queryCompilationContext, QuerySourceReferenceExpression querySourceReferenceExpression, IEntityType entityType) { var trackingInfo = new EntityTrackingInfo( _keyValueFactorySource, queryCompilationContext, querySourceReferenceExpression, entityType); return trackingInfo; }
private InternalEntityEntry NewInternalEntityEntry(IStateManager stateManager, IEntityType entityType, object entity) { if (!entityType.HasClrType()) { return new InternalShadowEntityEntry(stateManager, entityType, _metadataServices); } Debug.Assert(entity != null); return entityType.ShadowPropertyCount() > 0 ? (InternalEntityEntry)new InternalMixedEntityEntry(stateManager, entityType, _metadataServices, entity) : new InternalClrEntityEntry(stateManager, entityType, _metadataServices, entity); }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static int NavigationCount([NotNull] this IEntityType entityType) => GetCounts(entityType).NavigationCount;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IEnumerable <IForeignKey> GetDeclaredReferencingForeignKeys([NotNull] this IEntityType entityType) => entityType.Model.GetEntityTypes().SelectMany(et => et.GetDeclaredForeignKeys()) .Where(fk => fk.PrincipalEntityType == entityType);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IEnumerable <IDictionary <string, object> > GetData([NotNull] this IEntityType entityType, bool providerValues = false) => entityType.AsEntityType().GetData(providerValues);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IEnumerable <INavigation> FindDerivedNavigations( [NotNull] this IEntityType entityType, [NotNull] string navigationName) => entityType.GetDerivedTypes().SelectMany( et => et.GetDeclaredNavigations().Where(navigation => navigationName == navigation.Name));
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IEnumerable <IServiceProperty> GetDeclaredServiceProperties([NotNull] this IEntityType entityType) => entityType.AsEntityType().GetDeclaredServiceProperties();
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IEnumerable <IProperty> FindDerivedProperties( [NotNull] this IEntityType entityType, [NotNull] string propertyName) => entityType.GetDerivedTypes().SelectMany( et => et.GetDeclaredProperties().Where(property => propertyName.Equals(property.Name)));
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static Func <ISnapshot> GetEmptyShadowValuesFactory([NotNull] this IEntityType entityType) => entityType.AsEntityType().EmptyShadowValuesFactory;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IEnumerable <IEntityType> GetConcreteTypesInHierarchy([NotNull] this IEntityType entityType) => entityType.GetDerivedTypesInclusive().Where(et => !et.IsAbstract());
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IEnumerable <IPropertyBase> GetPropertiesAndNavigations( [NotNull] this IEntityType entityType) => entityType.GetProperties().Concat <IPropertyBase>(entityType.GetNavigations());
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static bool IsSameHierarchy([NotNull] this IEntityType firstEntityType, [NotNull] IEntityType secondEntityType) => firstEntityType.IsAssignableFrom(secondEntityType) || secondEntityType.IsAssignableFrom(firstEntityType);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IKey FindDeclaredPrimaryKey([NotNull] this IEntityType entityType) => entityType.BaseType == null?entityType.FindPrimaryKey() : null;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IEnumerable <IForeignKey> GetDeclaredForeignKeys([NotNull] this IEntityType entityType) => entityType.AsEntityType().GetDeclaredForeignKeys();
private static void SetValues(EntityEntry dbEntry, DataModificationEntry entry, Type entityType) { //StateEntry stateEntry = ((IAccessor<InternalEntityEntry>) dbEntry.StateEntry; IEntityType edmType = dbEntry.Metadata; if (entry.IsFullReplaceUpdate) { // The algorithm for a "FullReplaceUpdate" is taken from WCF DS ObjectContextServiceProvider.ResetResource, and is as follows: // Create a new, blank instance of the entity. Copy over the key values, and set any updated values from the client on the new instance. // Then apply all the properties of the new instance to the instance to be updated. This will set any unspecified // properties to their default value. object newInstance = Activator.CreateInstance(entityType); ChangeSetPreparer.SetValues(newInstance, entityType, entry.EntityKey); ChangeSetPreparer.SetValues(newInstance, entityType, entry.LocalValues); foreach (var property in edmType.GetProperties()) { object val; if (!entry.LocalValues.TryGetValue(property.Name, out val)) { PropertyInfo propertyInfo = entityType.GetProperty(property.Name); val = propertyInfo.GetValue(newInstance); } //stateEntry[property] = val; dbEntry.Property(property.Name).CurrentValue = val; } } else { // For some properties like DateTimeOffset, the backing EF property could be of a different type like DateTime, so we can't just // copy every property pair in DataModificationEntry to EF StateEntry, instead we let the entity type to do the conversion, by // first setting the EDM property (in DataModificationEntry) to a entity instance, then getting the EF mapped property from the // entity instance and set to StateEntry. object instance = null; foreach (var property in edmType.GetProperties()) { object val; var edmPropName = (string)property["EdmPropertyName"]; if (edmPropName != null && entry.LocalValues.TryGetValue(edmPropName, out val)) { if (instance == null) { instance = Activator.CreateInstance(entityType); } PropertyInfo edmPropInfo = entityType.GetProperty(edmPropName); edmPropInfo.SetValue(instance, val); PropertyInfo propertyInfo = entityType.GetProperty(property.Name); val = propertyInfo.GetValue(instance); } else if (!entry.LocalValues.TryGetValue(property.Name, out val)) { continue; } //stateEntry[property] = val; dbEntry.Property(property.Name).CurrentValue = val; } } }
public static string ShortName([NotNull] this IEntityType type) => ((ITypeBase)type).DisplayName();
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static int OriginalValueCount([NotNull] this IEntityType entityType) => GetCounts(entityType).OriginalValueCount;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static bool IsInDefinitionPath([NotNull] this IEntityType entityType, [NotNull] IEntityType targetType) => targetType.ClrType == null ? FindInDefinitionPath(entityType, targetType.Name) != null : FindInDefinitionPath(entityType, targetType.ClrType) != null;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static int RelationshipPropertyCount([NotNull] this IEntityType entityType) => GetCounts(entityType).RelationshipCount;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IEnumerable <IEntityType> GetDerivedTypesInclusive([NotNull] this IEntityType entityType) => new[] { entityType }.Concat(entityType.GetDerivedTypes());
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static int StoreGeneratedCount([NotNull] this IEntityType entityType) => GetCounts(entityType).StoreGeneratedCount;
public UpdateContextQueryBase(DbContext context, string schema, string table, List <IProperty> propertiesToUpdate, List <IProperty> propertiesForPivot, List <IProperty> propertiesToBulkLoad, IEntityType baseType, IDictionary <string, MemberInfo> propertyGetters) { this.PropertiesToUpdate = propertiesToUpdate; this.PropertiesForPivot = propertiesForPivot; this.PropertiesToBulkLoad = propertiesToBulkLoad; this.PropertyGetters = propertyGetters; this.Schema = schema; this.Table = table; this.Context = context; this.BaseType = baseType; }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static Func <ValueBuffer, ISnapshot> GetShadowValuesFactory([NotNull] this IEntityType entityType) => entityType.AsEntityType().ShadowValuesFactory;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> // Issue#11266 This method is being used by provider code. Do not break. public static IEnumerable <IIndex> GetDeclaredIndexes([NotNull] this IEntityType entityType) => entityType.GetIndexes().Where(p => p.DeclaringEntityType == entityType);
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static bool IsInDefinitionPath([NotNull] this IEntityType entityType, [NotNull] string targetTypeName) => FindInDefinitionPath(entityType, targetTypeName) != null;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static Func <InternalEntityEntry, ISnapshot> GetOriginalValuesFactory([NotNull] this IEntityType entityType) => entityType.AsEntityType().OriginalValuesFactory;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IForeignKey FindDeclaredOwnership([NotNull] this IEntityType entityType) => ((EntityType)entityType).FindDeclaredOwnership();
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static Func <InternalEntityEntry, ISnapshot> GetRelationshipSnapshotFactory([NotNull] this IEntityType entityType) => entityType.AsEntityType().RelationshipSnapshotFactory;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static PropertyCounts GetCounts([NotNull] this IEntityType entityType) => ((EntityType)entityType).Counts;
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static int PropertyCount([NotNull] this IEntityType entityType) => GetCounts(entityType).PropertyCount;
public Entity(IEntityType type) { EntityType = type; _values = new object[EntityType.Fields.Count]; }
/// <summary> /// This API supports the Entity Framework Core infrastructure and is not intended to be used /// directly from your code. This API may change or be removed in future releases. /// </summary> public static IEnumerable <INavigation> GetDeclaredNavigations([NotNull] this IEntityType entityType) => entityType.GetDeclaredForeignKeys() .Concat(entityType.GetDeclaredReferencingForeignKeys()) .SelectMany(foreignKey => foreignKey.FindNavigationsFrom(entityType)) .Distinct() .OrderBy(m => m.Name);