public void Returns_delegate_using_any_constructor_with_which_EntityConnection_can_be_used()
 {
     Assert.IsType <Normal>(DbCompiledModel.GetConstructorDelegate <Normal>()(new EntityConnection()));
     Assert.IsType <WithDbConnction>(DbCompiledModel.GetConstructorDelegate <WithDbConnction>()(new EntityConnection()));
     Assert.IsType <WithIDbConnction>(DbCompiledModel.GetConstructorDelegate <WithIDbConnction>()(new EntityConnection()));
     Assert.IsType <WithIDisposable>(DbCompiledModel.GetConstructorDelegate <WithIDisposable>()(new EntityConnection()));
     Assert.IsType <WithComponent>(DbCompiledModel.GetConstructorDelegate <WithComponent>()(new EntityConnection()));
     Assert.IsType <WithMarshalByRefObject>(DbCompiledModel.GetConstructorDelegate <WithMarshalByRefObject>()(new EntityConnection()));
     Assert.IsType <WithObject>(DbCompiledModel.GetConstructorDelegate <WithObject>()(new EntityConnection()));
 }
示例#2
0
        public TContext CreateObjectContext <TContext>(DbConnection existingConnection) where TContext : ObjectContext
        {
            Check.NotNull <DbConnection>(existingConnection, nameof(existingConnection));
            TContext context = (TContext)DbCompiledModel.GetConstructorDelegate <TContext>()(new EntityConnection(this._workspace.GetMetadataWorkspace(existingConnection), existingConnection));

            context.ContextOwnsConnection = true;
            if (string.IsNullOrEmpty(context.DefaultContainerName))
            {
                context.DefaultContainerName = this._workspace.DefaultContainerName;
            }
            foreach (Assembly assembly in this._workspace.Assemblies)
            {
                context.MetadataWorkspace.LoadFromAssembly(assembly);
            }
            return(context);
        }
 private static string GetConstructorUsed <TContext>() where TContext : ContextForConstruction
 {
     return(((TContext)DbCompiledModel.GetConstructorDelegate <TContext>()(new EntityConnection())).ConstructorUsed);
 }