public PhotoEntity Add(PhotoEntity t) { photo photo = new photo(); Mapper.Map(t, photo); using (this.mEntities = new photoshareEntities()) { this.mEntities.photos.AddObject(photo); if (t.Favorite) { favoritephoto favorite = new favoritephoto(); Mapper.Map(photo, favorite); this.mEntities.favoritephotos.AddObject(favorite); } this.mEntities.SaveChanges(); } return t; }
/// <summary> /// Create a new photo object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="owner">Initial value of the Owner property.</param> /// <param name="date">Initial value of the Date property.</param> /// <param name="fileName">Initial value of the FileName property.</param> /// <param name="albumId">Initial value of the AlbumId property.</param> public static photo Createphoto(global::System.Guid id, global::System.Guid owner, global::System.DateTime date, global::System.String fileName, global::System.Guid albumId) { photo photo = new photo(); photo.Id = id; photo.Owner = owner; photo.Date = date; photo.FileName = fileName; photo.AlbumId = albumId; return photo; }
/// <summary> /// Deprecated Method for adding a new object to the photos EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTophotos(photo photo) { base.AddObject("photos", photo); }