public int DeleteCarType(string type) { if (GlobalVariable.queryType == 0) { ALLCARTYPE carType = DB.ALLCARTYPES.Where(ct => ct.thisCarType.Equals(type)).SingleOrDefault(); DB.ALLCARTYPES.Attach(carType); if (carType == null) { return(0); } DB.ALLCARTYPES.Remove(carType); DB.SaveChanges(); return(1); } else { return(DB.DeleteCarTypeByType(type)); } }