コード例 #1
0
ファイル: IQueryBuilder.cs プロジェクト: Bikeman868/RestDB
        private void Example2()
        {
            IColumnQueryFactory cq      = null;
            IQueryBuilder       builder = null;

            var query = builder
                        // Delete users created in the last 7 days whose first name is 'martin' and who are under 18
                        .BeginTransaction()
                        .BeginFor("user").Function(q =>
            {
                var users      = q.Table["users"];
                var isNewMatch = cq.Create(users.Column["created"], CompareOperation.Greater, DateTime.UtcNow.AddDays(-7));
                return(users.MatchingRows(q.Transaction, new[] { isNewMatch }));
            })
                        .If()
                        .BeginAnd()
                        .Compare(CompareOperation.Similar).Field("firstName").Literal("martin")
                        .Compare(CompareOperation.Less).Field("age").Literal(18)
                        .EndAnd()
                        .Delete("user")
                        .EndFor()
                        .Commit()

                        // Build the query
                        .Build();
        }