public void DeleteRegion(Region region)
        {
            if ((region.EntityState == EntityState.Detached))
                this.ObjectContext.Regions.Attach(region);

            region.Locations.Load();
            region.Locations.Clear();

            region.BusinessAccount = null;

            if ((region.EntityState != EntityState.Detached))
            {
                this.ObjectContext.ObjectStateManager.ChangeObjectState(region, EntityState.Deleted);
            }
            else
            {
                this.ObjectContext.Regions.Attach(region);
                this.ObjectContext.Regions.DeleteObject(region);
            }
        }
 /// <summary>
 /// Create a new Region object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 public static Region CreateRegion(global::System.Guid id, global::System.String name, global::System.DateTime createdDate)
 {
     Region region = new Region();
     region.Id = id;
     region.Name = name;
     region.CreatedDate = createdDate;
     return region;
 }
        public void UpdateRegion(Region currentRegion)
        {
            currentRegion.LastModified = DateTime.UtcNow;
            currentRegion.LastModifyingUserId = CurrentUserAccount().Id;

            this.ObjectContext.Regions.AttachAsModified(currentRegion);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the Regions EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRegions(Region region)
 {
     base.AddObject("Regions", region);
 }