コード例 #1
0
 public AbstraXProviderDataProvider(DatabaseProviderDependencies dependencies, IServiceCollection services) : base(dependencies)
 {
     this.services           = services;
     this.identityMaps       = new Dictionary <IKey, IIdentityMap>();
     this.entityReferenceMap = new EntityReferenceMap(hasSubMap: true);
     dbSets = new List <DbSetProperty>();
 }
コード例 #2
0
    /// <summary>
    ///     This is an internal API that supports the Entity Framework Core infrastructure and not subject to
    ///     the same compatibility standards as public APIs. It may be changed or removed without notice in
    ///     any release. You should only use it directly in your code with extreme caution and knowing that
    ///     doing so can result in application failures when updating to a new Entity Framework Core release.
    /// </summary>
    public virtual void Update(
        InternalEntityEntry entry,
        EntityState state,
        EntityState?oldState)
    {
        var entityType = entry.EntityType;

        if (_hasSubMap &&
            entityType.HasSharedClrType)
        {
            _sharedTypeReferenceMap ??= new Dictionary <IEntityType, EntityReferenceMap>();

            if (!_sharedTypeReferenceMap.TryGetValue(entityType, out var sharedMap))
            {
                sharedMap = new EntityReferenceMap(hasSubMap: false);
                _sharedTypeReferenceMap[entityType] = sharedMap;
            }

            sharedMap.Update(entry, state, oldState);
        }
        else
        {
            var mapKey = entry.Entity ?? entry;

            if (oldState.HasValue)
            {
                Remove(mapKey, entityType, oldState.Value);
            }

            if (!oldState.HasValue ||
                state != EntityState.Detached)
            {
                switch (state)
                {
                case EntityState.Detached:
                    _detachedReferenceMap ??= new Dictionary <object, InternalEntityEntry>(LegacyReferenceEqualityComparer.Instance);
                    _detachedReferenceMap[mapKey] = entry;
                    break;

                case EntityState.Unchanged:
                    _unchangedReferenceMap ??=
                    new Dictionary <object, InternalEntityEntry>(LegacyReferenceEqualityComparer.Instance);
                    _unchangedReferenceMap[mapKey] = entry;
                    break;

                case EntityState.Deleted:
                    _deletedReferenceMap ??= new Dictionary <object, InternalEntityEntry>(LegacyReferenceEqualityComparer.Instance);
                    _deletedReferenceMap[mapKey] = entry;
                    break;

                case EntityState.Modified:
                    _modifiedReferenceMap ??= new Dictionary <object, InternalEntityEntry>(LegacyReferenceEqualityComparer.Instance);
                    _modifiedReferenceMap[mapKey] = entry;
                    break;

                case EntityState.Added:
                    _addedReferenceMap ??= new Dictionary <object, InternalEntityEntry>(LegacyReferenceEqualityComparer.Instance);
                    _addedReferenceMap[mapKey] = entry;
                    break;
                }
            }
        }
    }