internal VehicleBrand GetBrand(int id, ImageAnalyseDBEntities m_Entities)
        {
            VehicleBrand brand = null;

            brand = VehicleBrands.Where(t => t.Id == id).SingleOrDefault();

            return(brand);
        }
        public bool SaveChanges(ImageAnalyseDBEntities entities = null)
        {
            bool result = false;

            ImageAnalyseDBEntities dbEntities = entities == null ? m_Entities : entities;

            if (dbEntities != null)
            {
                dbEntities.SaveChanges();
            }

            return(result);
        }
        internal ImageAnalyseDBEntities GetImageAnalyseEntities()
        {
            ImageAnalyseDBEntities entities = new ImageAnalyseDBEntities(connectionString);

            System.Data.EntityClient.EntityConnection conn = entities.Connection as System.Data.EntityClient.EntityConnection;
            if (string.IsNullOrEmpty(m_dbConnString))
            {
                string ss = conn.StoreConnection.ConnectionString;
                m_dbConnString = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), Path.GetFileName(ss));
                MyLog4Net.Container.Instance.Log.DebugFormat("IVXBaseLib Database file location: {0}", m_dbConnString);
                m_dbConnString = string.Format("data source={0}", m_dbConnString);
            }
            conn.StoreConnection.ConnectionString = m_dbConnString;
            return(entities);
        }
        public VehicleBrandDAOService()
        {
            //Assembly asm = Assembly.GetExecutingAssembly();

            //string configFile = Path.Combine(Directory.GetParent(asm.Location).FullName, "IVXBaseLib.dll.config");
            //ExeConfigurationFileMap configFileMap = new ExeConfigurationFileMap();
            //configFileMap.ExeConfigFilename = configFile;
            //Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configFileMap, ConfigurationUserLevel.None);
            //LogService.GetLog("Service").DebugFormat("Configuration path:{0}", config.FilePath);


            m_Entities = new ImageAnalyseDBEntities(connectionString);
            System.Data.EntityClient.EntityConnection conn = m_Entities.Connection as System.Data.EntityClient.EntityConnection;
            if (string.IsNullOrEmpty(m_dbConnString))
            {
                string ss = conn.StoreConnection.ConnectionString;
                m_dbConnString = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), Path.GetFileName(ss));
                MyLog4Net.Container.Instance.Log.DebugFormat("IVXBaseLib Database file location: {0}", m_dbConnString);
                m_dbConnString = string.Format("data source={0}", m_dbConnString);
            }
            conn.StoreConnection.ConnectionString = m_dbConnString;
            VehicleBrands = new List <VehicleBrand>();
            VehicleBrands.AddRange(this.m_Entities.VehicleBrands);
        }