private void CopyCustomerDemographics(IOdb odb)
        {
            //Processing CustomerDemographics
            LogMessage("Reading CustomerDemographics...", false);
            var adapter1 = new CustomerDemographicsTableAdapter();
            var table1   = adapter1.GetData();

            LogMessage("processing " + table1.Count.ToString() + " rows", true);
            foreach (var row in table1)
            {
                LogMessage("CustomerDemographics: " + row.CustomerTypeID + " ...", false);

                var cd = new CustomerDemographics
                {
                    CustomerTypeID = row.CustomerTypeID,
                    CustomerDesc   = row.IsCustomerDescNull() ? null : row.CustomerDesc
                };

                odb.Store(cd);
                LogMessage("saved", true);
            }
            odb.Commit();

            LogMessage("Commit done, starting create index ...", false);
            odb.IndexManagerFor <CustomerDemographics>().AddUniqueIndexOn(
                "CustomerDemographics_CustomerTypeID_PK_index", CustomerDemographics.PK);
            odb.Commit();
            LogMessage(" index created.", true);

            long objectCount = NDbUtil.GetAllInstances <CustomerDemographics>(odb).Count;

            if (table1.Count == objectCount)
            {
                LogMessage(table1.Count + " objects saved", true);
            }
            else
            {
                LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true);
            }
            LogMessage("Done with CustomerDemographics" + Environment.NewLine, true);
        }
Exemple #2
0
        public void CopyCustomerDemographics()
        {
            //Processing CustomerDemographics
            LogMessage("Reading CustomerDemographics...", false);
            CustomerDemographicsTableAdapter adapter1 = new CustomerDemographicsTableAdapter();
            NorthwindDb4o.NorthwindDataSet.CustomerDemographicsDataTable table1 = adapter1.GetData();
            LogMessage("processing " + table1.Count.ToString() + " rows", true);
            foreach (NorthwindDb4o.NorthwindDataSet.CustomerDemographicsRow row in table1)
            {
                LogMessage("CustomerDemographics: " + row.CustomerTypeID.ToString() + " ...", false);

                CustomerDemographics cd = new CustomerDemographics();

                cd.CustomerTypeID = row.CustomerTypeID;
                cd.CustomerDesc = row.IsCustomerDescNull() ? null : row.CustomerDesc;

                container.Store(cd);
                LogMessage("saved", true);
            }
            container.Commit();
            long objectCount = Db4oUtil.GetAllInstances(container, typeof(CustomerDemographics)).Count;
            if (table1.Count == objectCount)
                LogMessage(table1.Count + " objects saved", true);
            else
                LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true);
            LogMessage("Done with CustomerDemographics" + Environment.NewLine, true);
        }
        private void CopyCustomerDemographics(IOdb odb)
        {
            //Processing CustomerDemographics
            LogMessage("Reading CustomerDemographics...", false);
            var adapter1 = new CustomerDemographicsTableAdapter();
            var table1 = adapter1.GetData();
            LogMessage("processing " + table1.Count.ToString() + " rows", true);
            foreach (var row in table1)
            {
                LogMessage("CustomerDemographics: " + row.CustomerTypeID + " ...", false);

                var cd = new CustomerDemographics
                             {
                                 CustomerTypeID = row.CustomerTypeID,
                                 CustomerDesc = row.IsCustomerDescNull() ? null : row.CustomerDesc
                             };

                odb.Store(cd);
                LogMessage("saved", true);
            }
            odb.Commit();

            LogMessage("Commit done, starting create index ...", false);
            odb.IndexManagerFor<CustomerDemographics>().AddUniqueIndexOn(
                "CustomerDemographics_CustomerTypeID_PK_index", CustomerDemographics.PK);
            odb.Commit();
            LogMessage(" index created.", true);

            long objectCount = NDbUtil.GetAllInstances<CustomerDemographics>(odb).Count;
            if (table1.Count == objectCount)
                LogMessage(table1.Count + " objects saved", true);
            else
                LogMessage("Error: " + table1.Count + " rows retrieved but " + objectCount + " objects were saved", true);
            LogMessage("Done with CustomerDemographics" + Environment.NewLine, true);
        }