/// <summary> /// 查找对应实体的类型上下文 /// </summary> /// <param name="entityType"></param> /// <returns></returns> internal TypedEntityContext FindTypeContext(Type entityType) { if (Disabled) return null; if (this._lastContext != null && this._lastContext.EntityType == entityType) { return this._lastContext; } TypedEntityContext res = null; if (this._contexts.TryGetValue(entityType, out res)) { this._lastContext = res; } return res; }
/// <summary> /// 查找或者直接创建某一特定实体类型的上下文对象。 /// </summary> /// <param name="entityType"></param> /// <returns></returns> internal TypedEntityContext GetOrCreateTypeContext(Type entityType) { if (Disabled) return new DisabledTypedEntityContext(); if (this._lastContext != null && this._lastContext.EntityType == entityType) { return this._lastContext; } TypedEntityContext res = null; if (!this._contexts.TryGetValue(entityType, out res)) { res = new TypedEntityContext { EntityType = entityType }; this._contexts.Add(entityType, res); } this._lastContext = res; return res; }