public void CopyRegions(IOdb odb, NorthwindDataSet dataSet)
        {
            //Processing Regions
            LogMessage("Reading Regions...", false);
            var adapter1 = new RegionTableAdapter();
            var table1 = adapter1.GetData();
            LogMessage("processing " + table1.Count.ToString() + " rows", true);
            foreach (var row in table1)
            {
                LogMessage("Regions: " + row.RegionID.ToString() + " ...", false);

                var r = new Region {RegionID = row.RegionID, RegionDescription = row.RegionDescription};

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

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

            long objectCount = NDbUtil.GetAllInstances<Region>(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 Regions" + Environment.NewLine, true);
        }
        public List <Region> GetAllRegions()
        {
            List <Region>      regions = new List <Region>();
            RegionTableAdapter adapter = new RegionTableAdapter();

            MultiLingualData.RegionDataTable table = adapter.GetAllRegions();
            foreach (MultiLingualData.RegionRow row in table)
            {
                regions.Add(MultiLingualHelper.ToRegionDTO(row));
            }
            return(regions);
        }
        public Region GetRegion(string regionCode)
        {
            if (string.IsNullOrEmpty(regionCode))
            {
                return(new Region());
            }
            RegionTableAdapter adapter = new RegionTableAdapter();

            MultiLingualData.RegionDataTable table = adapter.GetRegion(regionCode);
            if (table.Count == 0)
            {
                return(new Region());
            }
            return(MultiLingualHelper.ToRegionDTO(table[0]));
        }
        public void CopyRegions(IOdb odb, NorthwindDataSet dataSet)
        {
            //Processing Regions
            LogMessage("Reading Regions...", false);
            var adapter1 = new RegionTableAdapter();
            var table1   = adapter1.GetData();

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

                var r = new Region {
                    RegionID = row.RegionID, RegionDescription = row.RegionDescription
                };

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

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

            long objectCount = NDbUtil.GetAllInstances <Region>(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 Regions" + Environment.NewLine, true);
        }
Exemple #5
0
        public void CopyRegions()
        {
            //Processing Regions
            LogMessage("Reading Regions...", false);
            RegionTableAdapter adapter1 = new RegionTableAdapter();
            NorthwindDb4o.NorthwindDataSet.RegionDataTable table1 = adapter1.GetData();
            LogMessage("processing " + table1.Count.ToString() + " rows", true);
            foreach (NorthwindDb4o.NorthwindDataSet.RegionRow row in table1)
            {
                LogMessage("Regions: " + row.RegionID.ToString() + " ...", false);

                Region r = new Region();

                r.RegionID = row.RegionID;
                r.RegionDescription = row.RegionDescription;

                container.Store(r);
                LogMessage("saved", true);
            }
            container.Commit();
            long objectCount = Db4oUtil.GetAllInstances(container, typeof(Region)).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 Regions" + Environment.NewLine, true);
        }
Exemple #6
0
 public RegionDAOImpl()
 {
     adapter = new RegionTableAdapter();
 }