Exemple #1
0
        public static void PersonExample(DynamoDBContext ddbc)
        {
            // Insert 1 person
            ddbc.Insert(PersonFactory.getSpecificPerson());

            // Get 1 person
            Person person = ddbc.Get <Person>("uniqueid");

            // Batch Insert 100 Persons
            List <Person> persons = new List <Person>();

            for (int i = 0; i < 100; i++)
            {
                persons.Add(PersonFactory.getRandomPerson());
            }
            ddbc.BatchInsert(persons);

            // Scan for persons with age greater than 3500
            ScanFilterCondition sfc    = new ScanFilterCondition("Age", ScanOperator.GreaterThan, 1000);
            List <Person>       result = ddbc.Scan <Person>(new List <ScanFilterCondition>()
            {
                sfc
            }).ToList();

            // Delete all people in scan result.
            var idList = result.Select(x => x.Id).ToList();

            ddbc.BatchDelete(idList);

            // Count age up by 2 atomicly (Also works with negative numbers for counting down)
            ddbc.AtomicCounter("uniqueid", "Age", 2);

            // Conditional Update. Update Person's job only if great-grandfather's name is Troels
            Person personCondUpdate = new Person()
            {
                Id = "uniqueid"
            };

            personCondUpdate.Job = new Job()
            {
                JobName   = "CEO",
                Salary    = 9878984,
                Seniority = 12
            };

            ddbc.ConditionalUpdate(personCondUpdate, "Father.Mother.Father.Name", "Troels");
        }