public Country getCountryById(int idCountry)
        {
            CarpoolingDAL.Coutry co = new CarpoolingDAL.Coutry();
            try {
                var query = db.Coutries.Where(o => o.idCoutry == idCountry).First();
                co = query as CarpoolingDAL.Coutry;
            } catch (Exception) {
                co = null;
            }

            return(RepositoryUtility.createCoutryFromDALCoutry(co));
        }
        public Country getCountryByCity(City city)
        {
            CarpoolingDAL.City   ci = new CarpoolingDAL.City();
            CarpoolingDAL.Coutry co = new CarpoolingDAL.Coutry();
            try {
                var query = db.Cities.Where(o => o.idCity == city.Id).First();
                ci = query as CarpoolingDAL.City;
                var query2 = db.Coutries.Where(o => o.idCoutry == ci.idCoutry).First();
                co = query2 as CarpoolingDAL.Coutry;
            } catch (Exception) {
                co = null;
            }

            return(RepositoryUtility.createCoutryFromDALCoutry(co));
        }
        public Nation getStateByCountry(Country country)
        {
            CarpoolingDAL.Coutry co = new CarpoolingDAL.Coutry();
            CarpoolingDAL.State  st = new CarpoolingDAL.State();
            try {
                var query = db.Coutries.Where(o => o.idCoutry == country.Id).First();
                co = query as CarpoolingDAL.Coutry;
                var query2 = db.States.Where(o => o.idState == co.idCoutry).First();
                st = query2 as CarpoolingDAL.State;
            } catch (Exception) {
                st = null;
            }

            return(RepositoryUtility.createNationFromDALState(st));
        }
        public Nation getStateByCountry(Country country)
        {
            CarpoolingDAL.Coutry co = new CarpoolingDAL.Coutry();
            CarpoolingDAL.State st = new CarpoolingDAL.State();
            try {
                var query = db.Coutries.Where(o => o.idCoutry == country.Id).First();
                co = query as CarpoolingDAL.Coutry;
                var query2 = db.States.Where(o => o.idState == co.idCoutry).First();
                st = query2 as CarpoolingDAL.State;
            } catch (Exception) {
                st = null;
            }

            return RepositoryUtility.createNationFromDALState(st);
        }
        public Country getCountryById(int idCountry)
        {
            CarpoolingDAL.Coutry co = new CarpoolingDAL.Coutry();
            try {
                var query = db.Coutries.Where(o => o.idCoutry == idCountry).First();
                co = query as CarpoolingDAL.Coutry;
            } catch (Exception) {
                co = null;
            }

            return RepositoryUtility.createCoutryFromDALCoutry(co);
        }
        public Country getCountryByCity(City city)
        {
            CarpoolingDAL.City ci = new CarpoolingDAL.City();
            CarpoolingDAL.Coutry co = new CarpoolingDAL.Coutry();
            try {
                var query = db.Cities.Where(o => o.idCity == city.Id).First();
                ci = query as CarpoolingDAL.City;
                var query2 = db.Coutries.Where(o => o.idCoutry == ci.idCoutry).First();
                co = query2 as CarpoolingDAL.Coutry;
            } catch (Exception) {
                co = null;
            }

            return RepositoryUtility.createCoutryFromDALCoutry(co);
        }
 partial void DeleteCoutry(Coutry instance);
 partial void UpdateCoutry(Coutry instance);
 partial void InsertCoutry(Coutry instance);
		private void detach_Coutries(Coutry entity)
		{
			this.SendPropertyChanging();
			entity.State = null;
		}
		private void attach_Coutries(Coutry entity)
		{
			this.SendPropertyChanging();
			entity.State = this;
		}