Esempio n. 1
0
 public void SaveSliceWithWhiteList()
 {
     var values = new { DataInt = 5, DataLong = 3000000000L, DataString = "hello world", Garbage = "booooooo" };
     int id = -1;
     Assert.Throws(Is.InstanceOf<DbException>(), () => this.ConnectionFactory().Save("Test", values, out id));
     Assert.DoesNotThrow(() => this.ConnectionFactory().Save("Test",  values, out id, new[] { "DataInt", "DataLong", "DataString" }));
     Assert.AreEqual(1, id);
     this.ReadBackAndCheckValues(values, id);
 }
Esempio n. 2
0
        public void SaveAndReadBack()
        {
            var values = new { DataInt = 5, DataLong = 3000000000L, DataString = "hello world" };
            int id;
            this.ConnectionFactory().Save("Test", values, out id);
            Assert.AreEqual(1, id);

            this.ReadBackAndCheckValues(values, id);
        }
Esempio n. 3
0
 void RunWithMeasure()
 {
     Profiler.Reset();
     var s2 = "update test set Name = 'updated' where Id = 1".NonQuery(1);
     var s0 = "select * from Test where Id = 1".Query(rowCount: 1, columnCount: 3);
     var sqls = new[] {s2, s0};
     const int count = 10000;
     Profiler.Measure(() => Check(count, ReaderBatch(sqls)));
     Profiler.Measure(() => Check(ReaderBatch(1.While(i => i < count).SelectMany(i => sqls).ToArray())));
     Tracer.Line(Profiler.Format(hidden: 0));
 }
Esempio n. 4
0
        public void Contexts_can_be_associated_with_an_EntityConnection()
        {
            var connection = new EntityConnection();

            var contexts = new[]
                {
                    new ObjectContext(),
                    new ObjectContext(),
                    new ObjectContext(),
                };

            connection.AssociateContext(contexts[0]);

            Assert.Equal(new[] { contexts[0] }, connection.AssociatedContexts);

            connection.AssociateContext(contexts[1]);
            connection.AssociateContext(contexts[2]);

            foreach (var context in contexts)
            {
                Assert.Contains(context, connection.AssociatedContexts);
            }
        }
        private static MetadataWorkspace GetProviderSchemaMetadataWorkspace(
            IDbDependencyResolver resolver, string providerInvariantName, SystemDataCommon.DbConnection providerConnection,
            Version targetSchemaVersion)
        {
            Debug.Assert(resolver != null, "resolver != null");
            Debug.Assert(!string.IsNullOrWhiteSpace(providerInvariantName), "providerInvarianName cannot be null or empty");
            Debug.Assert(providerConnection != null, "providerConnection != null");
            Debug.Assert(EntityFrameworkVersion.IsValidVersion(targetSchemaVersion), "invalid targetSchemaVersion");

            string csdlName;
            string ssdlName;
            string mslName;
            if (targetSchemaVersion >= EntityFrameworkVersion.Version3)
            {
                csdlName = DbProviderManifest.ConceptualSchemaDefinitionVersion3;
                ssdlName = DbProviderManifest.StoreSchemaDefinitionVersion3;
                mslName = DbProviderManifest.StoreSchemaMappingVersion3;
            }
            else
            {
                csdlName = DbProviderManifest.ConceptualSchemaDefinition;
                ssdlName = DbProviderManifest.StoreSchemaDefinition;
                mslName = DbProviderManifest.StoreSchemaMapping;
            }

            var providerServices = resolver.GetService<DbProviderServices>(providerInvariantName);
            Debug.Assert(providerServices != null, "Trying to get unregistered provider.");

            var providerManifest =
                providerServices.GetProviderManifest(
                    providerServices.GetProviderManifestToken(providerConnection));

            var edmItemCollection = LoadEdmItemCollection(csdlName);
            var storeItemCollection = LoadStoreItemCollection(providerManifest, ssdlName);
            var mappingItemCollection = LoadMappingItemCollection(providerManifest, mslName, edmItemCollection, storeItemCollection);
            var workspace = new MetadataWorkspace(
                () => edmItemCollection,
                () => storeItemCollection,
                () => mappingItemCollection);

            // TODO: there is currently no public surface to do this (workitem 606 on codeplex)
            //// make the views generate here so we can wrap the provider schema problems
            //// in a ProviderIncompatibleException
            //ForceViewGeneration(workspace);

            return workspace;
        }
 protected override string GetDbProviderManifestToken(SystemDataCommon.DbConnection connection)
 {
     throw new NotImplementedException();
 }
 public LegacyDbCommandDefinitionWrapper(Legacy.DbCommandDefinition wrappedDbCommandDefinition)
 {
     _wrappedDbCommandDefinition = wrappedDbCommandDefinition;
 }