Ejemplo n.º 1
0
        /// <summary>
        /// Calls the base class because there may be some generic behavior in it
        /// Get the Generic object
        /// </summary>
        /// <typeparam name="T">generic type</typeparam>
        /// <returns>The generic object</returns>
        public override async Task <IQueryable <T> > GetAsync <T>()
        {
            await base.GetAsync <T>();

            var result = await DynamoDbContext.ScanAsync <T>(new List <ScanCondition>()).GetRemainingAsync();

            return(result.AsQueryable());
        }
        public async Task <ICollection <TDTO> > Get(ResourceRequest <TServiceQuery> request)
        {
            var policy = _dynamoDbResourceQuerablePolicy.Convert(request?.Query);

            var result = await DynamoDbContext.ScanAsync <TDTO>(
                policy.ScanConditions,
                policy.OperationConfig
                ).GetRemainingAsync();

            return(result);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Calls the base class because there may be some generic behavior in it
        /// Counts the quantity of documents
        /// </summary>
        /// <typeparam name="T">generic type</typeparam>
        /// <param name="predicate">lambda expression</param>
        /// <returns>Quantity of Document</returns>
        public override async Task <int> CountAsync <T>(Expression <Func <T, bool> > predicate)
        {
            await base.CountAsync <T>(predicate);

            List <ScanCondition> conditions = new List <ScanCondition>();

            IEnumerable <ExpressionAnalyzed> expressions = (IEnumerable <ExpressionAnalyzed>)_evaluatePredicate.Evaluate <T>(predicate);

            expressions.ToList().ForEach(x => {
                conditions.Add(new ScanCondition(x.PropertyName, this.ConvertEnum(x.OperatorBetweenPropAndValue.ExpressionType), x.PropertyValue));
            });

            var result = await DynamoDbContext.ScanAsync <T>(conditions).GetRemainingAsync();

            return(result.Count);
        }
Ejemplo n.º 4
0
        public async Task DynamoDbService_Should_List_Records_In_A_DynamoDb_Table()
        {
            var       tableName   = Guid.NewGuid().ToString();
            const int recordCount = 5;

            var dynamoDbOperationConfig = new DynamoDBOperationConfig()
            {
                OverrideTableName = tableName
            };

            await CreateTestTable(tableName);

            Table targetTable = DynamoDbContext.GetTargetTable <MovieEntity>(dynamoDbOperationConfig);
            IList <MovieEntity> movieEntities = new Fixture().CreateMany <MovieEntity>(recordCount).ToList();
            List <Document>     documents     = movieEntities
                                                .Select(entity =>
            {
                string serialize = JsonSerializer.Serialize(entity);
                Document item    = Document.FromJson(serialize);

                return(item);
            })
                                                .ToList();

            foreach (Document document in documents)
            {
                await targetTable.PutItemAsync(document);
            }


            dynamoDbOperationConfig.IndexName = TestConstants.MoiveTableMovieIdGsi;
            List <MovieEntity> returnedMovieEntities = await DynamoDbContext.ScanAsync <MovieEntity>(new List <ScanCondition>(), dynamoDbOperationConfig).GetRemainingAsync();

            Assert.NotNull(movieEntities);
            Assert.NotEmpty(movieEntities);
            Assert.Equal(recordCount, movieEntities.Count);
            Assert.All(returnedMovieEntities, movieEntity =>
            {
                MovieEntity entity = movieEntities.First(e => e.MovieId == movieEntity.MovieId);

                Assert.True(movieEntity.DeepEquals(entity));
            });
        }
Ejemplo n.º 5
0
        public async Task <ScanEntityResponse <TEntity> > ToResponseAsync(CancellationToken cancellationToken = default)
        {
            var tableName = _context.Config.Metadata.GetOrAddClassInfo(typeof(TEntity)).GetTableName();

            return(await _context.ScanAsync <TEntity>(tableName, _node, cancellationToken).ConfigureAwait(false));
        }
Ejemplo n.º 6
0
 public async Task <IEnumerable <DynamoDbMessage> > Scan()
 {
     return(await DynamoDbContext.ScanAsync <DynamoDbMessage>(new List <ScanCondition>(), new DynamoDBOperationConfig { OverrideTableName = DynamoDbMessageStoreTestConfiguration.TableName })
            .GetNextSetAsync()
            .ConfigureAwait(false));
 }