public int SaveBlob(IBlobDb blobDb, int? transactionNumber = null) { if (blobDb.InstanceId != _instanceId) throw new Exception("Attempt to save Blob with wrong InstanceId"); Blob record; var recordOld = new Blob(); if (blobDb.BlobId == 0) { record = new Blob(); Context.AddToBlobs(record); } else { record = Context.Blobs.Where(r => r.BlobId == blobDb.BlobId).First(); ReflectionHelper.CopyAllProperties(record, recordOld); } record.InstanceId = _instanceId; record.Data = blobDb.Data; Context.SaveChanges(); if (blobDb.BlobId == 0) { blobDb.BlobId = record.BlobId; LogToDb(UserId, "Blobs", record.BlobId, "I", XmlHelper.GetObjectXml(record), transactionNumber); } else { LogToDb(UserId, "Blobs", record.BlobId, "U", XmlHelper.GetDifferenceXml(recordOld, record), transactionNumber); } return blobDb.BlobId; }
public void AddToBlobs(Blob record) { _context.AddToBlobs(record); }
/// <summary> /// Create a new Blob object. /// </summary> /// <param name="blobId">Initial value of the BlobId property.</param> /// <param name="instanceId">Initial value of the InstanceId property.</param> /// <param name="data">Initial value of the Data property.</param> public static Blob CreateBlob(global::System.Int32 blobId, global::System.Int32 instanceId, global::System.Byte[] data) { Blob blob = new Blob(); blob.BlobId = blobId; blob.InstanceId = instanceId; blob.Data = data; return blob; }
/// <summary> /// Deprecated Method for adding a new object to the Blobs EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToBlobs(Blob blob) { base.AddObject("Blobs", blob); }