public void Insert(ResourceDto item) { using (var ctx = ObjectContextManager<PTrackerEntities>.GetManager("PTrackerEntities")) { var newItem = new Resource { FirstName = item.FirstName, LastName = item.LastName }; ctx.ObjectContext.AddToResources(newItem); ctx.ObjectContext.SaveChanges(); item.Id = newItem.Id; item.LastChanged = newItem.LastChanged; } }
/// <summary> /// Create a new Resource object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="lastName">Initial value of the LastName property.</param> /// <param name="firstName">Initial value of the FirstName property.</param> /// <param name="lastChanged">Initial value of the LastChanged property.</param> public static Resource CreateResource(global::System.Int32 id, global::System.String lastName, global::System.String firstName, global::System.Byte[] lastChanged) { Resource resource = new Resource(); resource.Id = id; resource.LastName = lastName; resource.FirstName = firstName; resource.LastChanged = lastChanged; return resource; }
/// <summary> /// Deprecated Method for adding a new object to the Resources EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToResources(Resource resource) { base.AddObject("Resources", resource); }