public CompaniesEditor(Company company = null)
        {
            InitializeComponent();

            if (company == null)
                company = new Company{CompanyId = Guid.NewGuid(), Name = "", Country = ""};

            CurrentCompany = company;
        }
 /// <summary>
 /// Create a new Company object.
 /// </summary>
 /// <param name="companyId">Initial value of the CompanyId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="country">Initial value of the Country property.</param>
 public static Company CreateCompany(global::System.Guid companyId, global::System.String name, global::System.String country)
 {
     Company company = new Company();
     company.CompanyId = companyId;
     company.Name = name;
     company.Country = country;
     return company;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Companies EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCompanies(Company company)
 {
     base.AddObject("Companies", company);
 }
        /// <summary>
        /// Method for deleting company from database.
        /// </summary>
        /// <param name="company">Company which will be deleted.</param>
        public void Delete(Company company)
        {
            if (company == null) throw new ArgumentNullException("company");

            if (company.CompanyId == Guid.Empty ||
                Context.Companies.Where(c => c.CompanyId == company.CompanyId).FirstOrDefault() == null) return;

            Context.DeleteObject(company);
            Context.SaveChanges();
            RefreshCache(OrderByField);
        }
 /// <summary>
 /// Method which will check company name in collection of already saved Companies, to find same. 
 /// I.e. Company name must be unique value, if not you will get false value as result.
 /// </summary>
 /// <param name="company">Company which will be checked.</param>
 /// <returns>
 /// false - Company name is not Unique.
 /// true - Company name is unique.
 /// </returns>
 public bool CheckCompanyNameForUnique(Company company)
 {
     return !company.IsCompanyNameUnique(Context);
 }
        /// <summary>
        /// Method which discards changes in Company, and loads Company state from database.
        /// </summary>
        /// <param name="company">Company which will be reverted.</param>
        public void Revert(Company company)
        {
            if (company == null) throw new ArgumentNullException("company");
            if (company.CompanyId == Guid.Empty ||
                Context.Companies.Where(c => c.CompanyId == company.CompanyId).FirstOrDefault() == null) return;

            Context.Refresh(RefreshMode.StoreWins, company);
        }