コード例 #1
0
 public InternalEntityEntry(InternalContext internalContext, IEntityStateEntry stateEntry)
 {
     this._internalContext = internalContext;
     this._stateEntry      = stateEntry;
     this._entity          = stateEntry.Entity;
     this._entityType      = ObjectContextTypeCache.GetObjectType(this._entity.GetType());
 }
コード例 #2
0
        // <summary>
        // Initializes a new instance of the <see cref="InternalEntityEntry" /> class.
        // </summary>
        // <param name="internalContext"> The internal context. </param>
        // <param name="stateEntry"> The state entry. </param>
        public InternalEntityEntry(InternalContext internalContext, IEntityStateEntry stateEntry)
        {
            DebugCheck.NotNull(internalContext);
            DebugCheck.NotNull(stateEntry);
            Debug.Assert(stateEntry.Entity != null);

            _internalContext = internalContext;
            _stateEntry      = stateEntry;
            _entity          = stateEntry.Entity;
            _entityType      = ObjectContextTypeCache.GetObjectType(_entity.GetType());
        }
コード例 #3
0
        public virtual IInternalSetAdapter Set(Type entityType)
        {
            entityType = ObjectContextTypeCache.GetObjectType(entityType);
            IInternalSetAdapter internalSet;

            if (!this._nonGenericSets.TryGetValue(entityType, out internalSet))
            {
                internalSet = this.CreateInternalSet(entityType, this._genericSets.TryGetValue(entityType, out internalSet) ? internalSet.InternalSet : (IInternalSet)null);
                this._nonGenericSets.Add(entityType, internalSet);
            }
            return(internalSet);
        }
コード例 #4
0
 public InternalEntityEntry(InternalContext internalContext, object entity)
 {
     this._internalContext = internalContext;
     this._entity          = entity;
     this._entityType      = ObjectContextTypeCache.GetObjectType(this._entity.GetType());
     this._stateEntry      = this._internalContext.GetStateEntry(entity);
     if (this._stateEntry != null)
     {
         return;
     }
     this._internalContext.Set(this._entityType).InternalSet.Initialize();
 }
コード例 #5
0
        public virtual IDbSet <TEntity> Set <TEntity>() where TEntity : class
        {
            if (typeof(TEntity) != ObjectContextTypeCache.GetObjectType(typeof(TEntity)))
            {
                throw Error.CannotCallGenericSetWithProxyType();
            }
            IInternalSetAdapter internalSetAdapter;

            if (!this._genericSets.TryGetValue(typeof(TEntity), out internalSetAdapter))
            {
                internalSetAdapter = (IInternalSetAdapter) new DbSet <TEntity>(this._nonGenericSets.TryGetValue(typeof(TEntity), out internalSetAdapter) ? (InternalSet <TEntity>)internalSetAdapter.InternalSet : new InternalSet <TEntity>(this));
                this._genericSets.Add(typeof(TEntity), internalSetAdapter);
            }
            return((IDbSet <TEntity>)internalSetAdapter);
        }
コード例 #6
0
        // <summary>
        // Initializes a new instance of the <see cref="InternalEntityEntry" /> class for an
        // entity which may or may not be attached to the context.
        // </summary>
        // <param name="internalContext"> The internal context. </param>
        // <param name="entity"> The entity. </param>
        public InternalEntityEntry(InternalContext internalContext, object entity)
        {
            DebugCheck.NotNull(internalContext);
            DebugCheck.NotNull(entity);

            _internalContext = internalContext;
            _entity          = entity;
            _entityType      = ObjectContextTypeCache.GetObjectType(_entity.GetType());

            _stateEntry = _internalContext.GetStateEntry(entity);
            if (_stateEntry == null)
            {
                // This will cause the context and model to be initialized and will throw an exception
                // if the entity type is not part of the model.
                _internalContext.Set(_entityType).InternalSet.Initialize();
            }
        }