コード例 #1
0
        /// <summary>
        /// The Table Service supports two main types of insert operations.
        ///  1. Insert - insert a new entity. If an entity already exists with the same PK + RK an exception will be thrown.
        ///  2. Replace - replace an existing entity. Replace an existing entity with a new entity.
        ///  3. Insert or Replace - insert the entity if the entity does not exist, or if the entity exists, replace the existing one.
        ///  4. Insert or Merge - insert the entity if the entity does not exist or, if the entity exists, merges the provided entity properties with the already existing ones.
        /// </summary>
        /// <param name="table">The sample table name</param>
        /// <param name="entity">The entity to insert or merge</param>
        /// <returns></returns>
        private static ImageProcessJobEntity InsertOrMergeEntity(CloudTable table, ImageProcessJobEntity entity)
        {
            TableOperation insertOrMergeOperation = TableOperation.InsertOrMerge(entity);

            TableResult           result   = table.Execute(insertOrMergeOperation);
            ImageProcessJobEntity inserted = result.Result as ImageProcessJobEntity;

            return(inserted);
        }
コード例 #2
0
        public static ImageProcessJobEntity Get(string orderId)
        {
            CloudTable table = CreateTable();

            TableOperation        retrieveOperation = TableOperation.Retrieve <ImageProcessJobEntity>(AccountId, orderId);
            TableResult           result            = table.Execute(retrieveOperation);
            ImageProcessJobEntity job = result.Result as ImageProcessJobEntity;

            return(job);
        }
コード例 #3
0
        /// <summary>
        /// Demonstrate basic Table CRUD operations.
        /// </summary>
        /// <param name="table">The sample table</param>
        public static void Crate(string orderId, string imageId)
        {
            // Create or reference an existing table
            CloudTable table = CreateTable();

            ImageProcessJobEntity job = new ImageProcessJobEntity(AccountId, orderId)
            {
                Status     = "REQUEST",
                ImageId    = imageId,
                CreateTime = DateTime.Now,
                UpdateTime = DateTime.Now
            };

            job = InsertOrMergeEntity(table, job);
        }
コード例 #4
0
        public static void Update(ImageProcessJobEntity entity)
        {
            CloudTable table = CreateTable();

            InsertOrMergeEntity(table, entity);
        }