TechSmith.Hyde.Table.TableItem.Create C# (CSharp) Method

Create() public static method

public static Create ( dynamic entity, string partitionKey, string rowKey, ReservedPropertyBehavior reservedPropertyBehavior = ReservedPropertyBehavior.Throw ) : TableItem
entity dynamic
partitionKey string
rowKey string
reservedPropertyBehavior ReservedPropertyBehavior
return TableItem
        public static TableItem Create( dynamic entity, string partitionKey, string rowKey, ReservedPropertyBehavior reservedPropertyBehavior = ReservedPropertyBehavior.Throw )
        {
            bool throwOnReservedPropertyName = reservedPropertyBehavior == ReservedPropertyBehavior.Throw;
             TableItem item = entity is IDynamicMetaObjectProvider ?
            CreateFromDynamicMetaObject( entity, throwOnReservedPropertyName ) :
            CreateFromType( entity, throwOnReservedPropertyName );

             if ( item.PartitionKey != null && item.PartitionKey != partitionKey )
             {
            throw new ArgumentException( string.Format( "Entity defines PartitionKey: {0} but it conflicts with partitionKey argument: {1}", item.PartitionKey, partitionKey ) );
             }
             item.PartitionKey = partitionKey;

             if ( item.RowKey != null && item.RowKey != rowKey )
             {
            throw new ArgumentException( string.Format( "Entity defines RowKey: {0} but it conflicts with rowKey argument: {1}", item.RowKey, rowKey ) );
             }
             item.RowKey = rowKey;

             return item;
        }

Same methods

TableItem::Create ( dynamic entity, ReservedPropertyBehavior reservedPropertyBehavior = ReservedPropertyBehavior.Throw ) : TableItem

Usage Example

Beispiel #1
0
        /// <summary>
        /// Remove the instance from table storage
        /// </summary>
        /// <param name="tableName">Name of the table</param>
        /// <param name="instance">the instance to delete</param>
        /// <param name="conflictHandling">Method for handling ETag conflicts</param>
        public void Delete(string tableName, dynamic instance, ConflictHandling conflictHandling)
        {
            TableItem tableItem = TableItem.Create(instance, _reservedPropertyBehavior);

            if (tableItem.ETag == null)
            {
                Delete(tableName, tableItem.PartitionKey, tableItem.RowKey);
            }
            else
            {
                _context.DeleteItem(tableName, tableItem, conflictHandling);
            }
        }
All Usage Examples Of TechSmith.Hyde.Table.TableItem::Create