/// <summary> /// Exclusively retrieves the entities. /// </summary> /// <param name="tableName">Name of the Db table.</param> /// <param name="filter">Order by this field.</param> /// <param name="takeRows">Take this amount of rows.</param> /// <returns></returns> public IEnumerable <Entity> ExclusivelyRetrieveEntities(string tableName, string filter, int takeRows) { string filterExpression = filter.Replace("\'", "\""); return(DatastoreTable.FromTableName(tableName)(_context) .Where(filterExpression) .ToList()); }
/// <summary> /// Exclusively retrieves the entities. /// </summary> /// <param name="tableName">Name of the Db table.</param> /// <param name="filter">Order by this field.</param> /// <param name="takeRows">Take this amount of rows.</param> /// <returns></returns> public IEnumerable <Entity> ExclusivelyRetrieveEntities(string tableName, string filter, int takeRows) { DatastoreTable.EnsureTableNameIsKnown(tableName); string filterExpression = filter.Replace("\'", "\""); return(DatastoreTable .FromTableName(tableName)(_context) .Where(filterExpression) .OrderBy(e => e.InsertionTime) .Take(takeRows) .ToList()); }
/// <summary> /// Delete the Messages Entities that are inserted passed a given <paramref name="retentionPeriod"/> /// and has a <see cref="Operation"/> within the given <paramref name="allowedOperations"/>. /// </summary> /// <param name="tableName"></param> /// <param name="retentionPeriod">The retention period.</param> /// <param name="allowedOperations">The allowed operations.</param> public void BatchDeleteOverRetentionPeriod( string tableName, TimeSpan retentionPeriod, IEnumerable <Operation> allowedOperations) { IQueryable <Entity> entities = DatastoreTable.FromTableName(tableName)(_context) .Cast <Entity>() .Where(x => x.InsertionTime < DateTimeOffset.Now.Subtract(retentionPeriod) && allowedOperations.Contains(GetOperation[tableName](x))); _context.RemoveRange(entities); _context.SaveChanges(); }