TableEntity

Namespace: Azure.Data.Tables
We found 10 examples in language CSharp for this search. You will see 46 fragments of code.
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void CreateTableRepositoryInstance_WithoutConfiguration_WithException()
        {
            TableRepository<TableEntity> repository = new TableRepository<TableEntity>(null);
        }

        [TestMethod]
        public void CreateTableRepositoryInstance_WithDefaultConfiguration_WithSuccess()
        {
            TableRepository<TableEntity> repository = new TableRepository<TableEntity>(
                TableStorageConfiguration.CreateDefault(
                    Helper.DailyTableName,
                    Helper.StorageConnectionString));
        }

        [TestMethod]
        public void InsertEntity_WithSuccess()
        {
            TableRepository<TableEntity> repository = new TableRepository<TableEntity>(
                TableStorageConfiguration.CreateDefault(
                    Helper.DailyTableName,
                    Helper.StorageConnectionString));
            repository.Insert(new TableEntity(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()));
        }

        [TestMethod]
        public async Task InsertEntity_Async_WithSuccess()
        {
            TableRepository<TableEntity> repository = new TableRepository<TableEntity>(
                TableStorageConfiguration.CreateDefault(
                    Helper.DailyTableName,
                    Helper.StorageConnectionString));
            await repository.InsertAsync(new TableEntity(Guid.NewGuid().ToString(), Guid.NewGuid().ToString()));
        }


        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void CreateInstance_WithNullQueryAndNullCacheKey_WithException()
        {
            TableStorageQueryCache<TableEntity> queryCache = new TableStorageQueryCache<TableEntity>(null);
        }
        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void CreateInstance_WithNullQuery_WithException()
        {
            TableStorageQueryCache<TableEntity> queryCache = new TableStorageQueryCache<TableEntity>(null);
        }
        [TestMethod]
        public void CreateInstance_WithAllParameters_WithSuccess()
        {
            TableStorageQueryCache<TableEntity> queryCache = new TableStorageQueryCache<TableEntity>(
                new EmptyQuery(),
                new MemoryCache(CryptographyHelper.ComputeSHA1Hash(Guid.NewGuid().ToString())),
                new CacheItemPolicy());
        }
        [TestMethod]
        public async Task ExecuteAsync_WithSuccess()
        {
            TableStorageQueryCache<TableEntity> queryCache = new TableStorageQueryCache<TableEntity>(
                new EmptyQuery(),
                new MemoryCache(CryptographyHelper.ComputeSHA1Hash(Guid.NewGuid().ToString())),
                new CacheItemPolicy());
            CloudTable table = CreateTestTable();
            await queryCache.Execute(table);
        }

        [TestMethod]
        public async Task ExecuteAsync_WithCache_WithSuccess()
        {
            RandomResultQuery query = new RandomResultQuery();
            TableStorageQueryCache<TableEntity> queryCache = new TableStorageQueryCache<TableEntity>(query);
            CloudTable table = CreateTestTable();
            var expected = await queryCache.Execute(table);
            var actual = await queryCache.Execute(table);
            CollectionAssert(expected, actual);
        }

            public Task<ICollection<TableEntity>> Execute(CloudTable table)
            {
                return Task.FromResult<ICollection<TableEntity>>(new List<TableEntity>());
            }

        IEnumerable<TableEntity> GetProduct();
        IEnumerable<TableEntity> GetAllRecords();
        IQueryable<TableEntity> GetAllRecordsIQueryable();
        void Add(TableEntity entity);
        void Update(TableEntity entity);
        void UpdateByWhereClause(Expression<Func<TableEntity, bool>> wherePredict, Action<TableEntity> ForEachPredict);


        [Fact]
        public void InsertOrMergeEntity_Ok()
        {
            //Arrange
            var tableEntity = new DynamicTableEntity();
            var (cloudTableMock, pool) =
                CreateTablePoolWithMockForExecute(tableEntity, TableOperationType.InsertOrMerge, SetupExecute);

            //Act & Assert
            TableStorageHelpers.InsertOrMergeEntity(pool, tableEntity).Should().Be(tableEntity);
            cloudTableMock.Verify();
        }

        [Fact]
        public void InsertOrReplaceEntity_Ok()
        {
            //Arrange
            var tableEntity = new DynamicTableEntity();
            var (cloudTableMock, pool) =
                CreateTablePoolWithMockForExecute(tableEntity, TableOperationType.InsertOrReplace, SetupExecute);

            //Act & Assert
            TableStorageHelpers.InsertOrReplaceEntity(pool, tableEntity).Should().Be(tableEntity);
            cloudTableMock.Verify();
        }

        [Fact]
        public void DeleteEntity_Ok()
        {
            //Arrange
            var tableEntity = new DynamicTableEntity();
            var (cloudTableMock, pool) =
                CreateTablePoolWithMockForExecute(tableEntity, TableOperationType.Delete, SetupExecute);

            //Act & Assert
            cloudTableMock.Verify();
            TableStorageHelpers.Delete(pool, "partitionKey", "rowKey"); // no exceptions
        }


        public IEnumerable<TableEntity> GetProduct()
        {
            return _dbSet.ToList();
        }

        public void Add(TableEntity entity)
        {
            _dbSet.Add(entity);
            _dbEntity.SaveChanges();
        }

        public IEnumerable<TableEntity> GetAllRecords()
        {
            return _dbSet.ToList();
        }

        public IQueryable<TableEntity> GetAllRecordsIQueryable()
        {
            return _dbSet;
        }

        public TableEntity GetFirstOrDefault(int recordID)
        {
            return _dbSet.Find(recordID);
        }

        public TableEntity GetFirstOrDefaultByParameter(Expression<Func<TableEntity, bool>> wherePredict)
        {
            return _dbSet.Where(wherePredict).FirstOrDefault();
        }


        public async Task<TableEntity> Add(TableEntity tableEntity)
        {
            await _dataBaseContext.Tables.AddAsync(tableEntity);
            await _dataBaseContext.SaveChangesAsync();

            return tableEntity;
        }

        public void Delete(TableEntity tableEntity)
        {
            _dataBaseContext.Tables.Remove(tableEntity);
            _dataBaseContext.SaveChangesAsync(); 
        }

        public TableEntity Get(TableEntity tableEntity) => _dataBaseContext.Tables.FirstOrDefault(t => t.Number == tableEntity.Number);

        public TableEntity Get(string guid) => _dataBaseContext.Tables.FirstOrDefault(t => t.Id == guid);

        public TableEntity Get(int number) => _dataBaseContext.Tables.FirstOrDefault(t => t.Number == number);

        public IQueryable<TableEntity> GetAll() => _dataBaseContext.Tables.ToList().AsQueryable();

        Task<TableEntity> Add(TableEntity tableEntity);
        void Update(TableEntity tableEntity);
        void Delete(TableEntity tableEntity);
        IQueryable<TableEntity> GetAll();
        TableEntity Get(TableEntity tableEntity);
        TableEntity Get(string guid);


        public void Insert(CloudTable cloudTable, TableEntity tableEntity)
        {
            var insertOperation = TableOperation.Insert(tableEntity);
            cloudTable.Execute(insertOperation);
        }

        // This one is not working for me today
        public async void InsertAsync(CloudTable cloudTable, TableEntity tableEntity)
        {
            var insertOperation = TableOperation.Insert(tableEntity);
            await cloudTable.ExecuteAsync(insertOperation);
        }

        public async void DeleteAsync(CloudTable cloudTable, TableEntity tableEntity)
        {
            var deleteOperation = TableOperation.Delete(tableEntity);
            await cloudTable.ExecuteAsync(deleteOperation);
        }

        public async void InsertOrReplaceAsync(CloudTable cloudTable, TableEntity tableEntity, string partitionKey, string rowKey)
        {
            tableEntity.PartitionKey = partitionKey;
            tableEntity.RowKey = rowKey;
            //"last-write-wins" strategy
            tableEntity.ETag = "*";
            var insertOrReplaceOperation = TableOperation.InsertOrReplace(tableEntity);
            await cloudTable.ExecuteAsync(insertOrReplaceOperation);
        }


		/// <summary>
		/// Get collection of all tableEntity
		/// </summary>
		/// <param name="session">User's session identifier.</param>
		/// <returns>Collection of all TableEntity</returns>
		/// <exception cref="UtnEmallBusinessLogicException">
		/// If an UtnEmallDataAccessException occurs in DataModel.
		/// </exception>
		public Collection<TableEntity> GetAllTable(string session)
		{
			return GetAllTable(true, session);
		} 

        protected abstract DbParameter[] Ricerca_Parametri(TableEntity entita);
        protected abstract TableEntity Carica_RecordSenzaAudit(ref DbDataReader dr);

        protected string getQuery(string NomeEvento)
        {
            return cDB.LeggiQuery(typeof(TableEntity).Name + "." + NomeEvento);
        }

        public cRisultatoSQL<System.Data.DataTable> Ricerca(int MaxRows, TableEntity entita)
        {
            try
            {
                return new cRisultatoSQL<System.Data.DataTable>(cDB.EseguiSQLDataTable(getQuery(cDB.eTipoEvento.Ricerca), Ricerca_Parametri(entita), MaxRows));
            }
            catch (System.Exception ex)
            {
                return new cRisultatoSQL<System.Data.DataTable>(ex);
            }
        }

Azure.Data.Tables.TableEntity : ITableEntity, IDictionary

Constructors :

public TableEntity()
public TableEntity(String partitionKey = , String rowKey = )
public TableEntity(IDictionary<String, Object> values = )

Methods :

public String get_PartitionKey()
public Void set_PartitionKey(String value = )
public String get_RowKey()
public Void set_RowKey(String value = )
public Nullable<DateTimeOffset> get_Timestamp()
public Void set_Timestamp(Nullable<DateTimeOffset> value = )
public ETag get_ETag()
public Void set_ETag(ETag value = )
public String GetString(String key = )
public BinaryData GetBinaryData(String key = )
public Byte[] GetBinary(String key = )
public Nullable<Boolean> GetBoolean(String key = )
public Nullable<DateTime> GetDateTime(String key = )
public Nullable<DateTimeOffset> GetDateTimeOffset(String key = )
public Nullable<Double> GetDouble(String key = )
public Nullable<Guid> GetGuid(String key = )
public Nullable<Int32> GetInt32(String key = )
public Nullable<Int64> GetInt64(String key = )
public Object get_Item(String key = )
public Void set_Item(String key = , Object value = )
public ICollection<String> get_Keys()
public Int32 get_Count()
public Void Add(String key = , Object value = )
public Boolean ContainsKey(String key = )
public Boolean Remove(String key = )
public Boolean TryGetValue(String key = , Object& value = )
public Void Clear()
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()