public void CopyData(DataContext db, Guid sourceDocumentID) { using (var sourceStream = new DocumentStream(db, sourceDocumentID)) { using (var destinationStream = new DocumentStream(db, this.ID)) { sourceStream.CopyTo(destinationStream); this.Length = sourceStream.Length; destinationStream.Flush(); } sourceStream.Flush(); } }
public void CopyData(DataContext db, Guid sourceDocumentID) { DateTime contentCreated = DateTime.UtcNow; using (var sourceStream = new DocumentStream(db, sourceDocumentID)) { using (var destinationStream = new DocumentStream(db, this.ID)) { sourceStream.CopyTo(destinationStream); this.Length = sourceStream.Length; destinationStream.Flush(); } sourceStream.Flush(); } db.Database.ExecuteSqlCommand($"UPDATE Documents SET ContentModifiedOn = GETUTCDATE(), ContentCreatedOn = '{ contentCreated }' WHERE ID = '{ this.ID.ToString("D") }'"); }