public void DeleteSubLocation(SubLocation subLocation)
        {
            var loadedSubLocation = this.ObjectContext.SubLocations.FirstOrDefault(sl => sl.Id == subLocation.Id);

            if (loadedSubLocation != null)
                this.ObjectContext.Detach(loadedSubLocation);

            if (subLocation.EntityState == EntityState.Detached)
                this.ObjectContext.SubLocations.Attach(subLocation);
            this.ObjectContext.SubLocations.DeleteObject(subLocation);
        }
        public void UpdateSubLocation(SubLocation currentSubLocation)
        {
            currentSubLocation.LastModified = DateTime.UtcNow;
            currentSubLocation.LastModifyingUserId = CurrentUserAccount().Id;

            this.ObjectContext.SubLocations.AttachAsModified(currentSubLocation);
        }
Esempio n. 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the SubLocations EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToSubLocations(SubLocation subLocation)
 {
     base.AddObject("SubLocations", subLocation);
 }
 public void InsertSubLocation(SubLocation subLocation)
 {
     if ((subLocation.EntityState != EntityState.Detached))
     {
         this.ObjectContext.ObjectStateManager.ChangeObjectState(subLocation, EntityState.Added);
     }
     else
     {
         this.ObjectContext.SubLocations.AddObject(subLocation);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Create a new SubLocation object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="number">Initial value of the Number property.</param>
 /// <param name="createdDate">Initial value of the CreatedDate property.</param>
 public static SubLocation CreateSubLocation(global::System.Guid id, global::System.String name, global::System.Int32 number, global::System.DateTime createdDate)
 {
     SubLocation subLocation = new SubLocation();
     subLocation.Id = id;
     subLocation.Name = name;
     subLocation.Number = number;
     subLocation.CreatedDate = createdDate;
     return subLocation;
 }