コード例 #1
0
ファイル: BlobRepository.cs プロジェクト: urise/JohanCorner
        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;
        }
コード例 #2
0
 public void AddToBlobs(Blob record)
 {
     _context.AddToBlobs(record);
 }
コード例 #3
0
 /// <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;
 }
コード例 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Blobs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBlobs(Blob blob)
 {
     base.AddObject("Blobs", blob);
 }