public List <Brand> GetBrand() { try { Brand brand = new Brand(); DataTable dt = _branddal.GetBrand(); List <Brand> brands = new List <Brand>(); foreach (DataRow dr in dt.Rows) { brands.Add(new Brand { id = Convert.ToInt32(dr["id"]), name = string.IsNullOrEmpty(dr["name"].ToString()) ? "" : dr["name"].ToString(), }); } return(brands); } catch (Exception e) { throw new Exception(e.Message); } }