コード例 #1
0
        static DynDocument QueryDocument()
        {
            // Build a document query that return employees that has a salary greater than $40k/year using a dynamic LINQ query filter.
            dynamic storage = new QueryableStorage <DynDocument>("mongodb://localhost/ConsoleExample");
            QueryableCollection <DynDocument> employeesCollection = storage.EmployeesColl;
            var employeeQuery = employeesCollection
                                // Query for salary greater than $40k and born later than early '95.
                                .Where("Salary > 40000 and Birthdate > DateTime(1995, 1, 1)")
                                // Projection makes sure that we only return Birthdate and no other properties.
                                .Select("new(Birthdate)");

            // Use a dynamic type so that we can get access to the document's dynamic properties
            return(employeeQuery.Cast <DynDocument>().First());
        }
コード例 #2
0
        public static void DeleteOldLogEntities()
        {
            // Get a reference to the table storage, example just uses the development storage
            dynamic storage = new QueryableStorage <DynEntity>("UseDevelopmentStorage=true");

            // Get a reference to the table named "LogTable"
            QueryableTable <DynEntity> logTable = storage.LogTable;
            var query = logTable.Where("Timestamp > @0", DateTime.UtcNow.AddDays(-1));

            // Delete all returned log entities
            foreach (var entity in query)
            {
                logTable.Delete(entity.PartitionKey, entity.RowKey);
            }
        }