Esempio n. 1
0
        public void TestGrouping()
        {
            const string NAME = "Security.User";

            var grouping = Grouping.Group("Status");

            grouping.Aggregates.Count("*");

            var context = new DataSelectContext(_accessor,
                                                NAME,     //name
                                                null,     //entityType
                                                grouping, //grouping
                                                Condition.Equal("UserId", 100) | (Condition.Like("Modifier.Name", "Popeye*") & Condition.GreaterThan("CreatedTime", DateTime.Today)),
                                                null,     //schema
                                                null,     //paging
                                                Sorting.Descending("UserId") + Sorting.Ascending("Creator.Name"));

            var statements = context.Build();

            Assert.NotNull(statements);
            Assert.NotEmpty(statements);

            var command = context.Session.Build(statements.First());

            Assert.NotNull(command);
            Assert.NotNull(command.CommandText);
            Assert.True(command.CommandText.Length > 0);
            Assert.True(command.Parameters.Count > 0);

            System.Diagnostics.Debug.WriteLine(command.CommandText);
        }
Esempio n. 2
0
        public void TestCollectionProperties()
        {
            const string NAME = "Security.Role";

            var schema = _accessor.Schema.Parse(NAME, "*, Creator{Modifier{*}}, Users(~CreatedTime){*, Modifier{*}}", typeof(Models.IRoleModel));

            var context = new DataSelectContext(_accessor,
                                                NAME,              //name
                                                schema.EntityType, //entityType
                                                null,              //grouping
                                                Condition.Between("RoleId", 10, 100) | Condition.Like("Modifier.Name", "Popeye*"),
                                                schema,            //schema
                                                null,              //paging
                                                Sorting.Descending("RoleId") + Sorting.Ascending("Creator.Name"));

            var statements = context.Build();

            Assert.NotNull(statements);
            Assert.NotEmpty(statements);

            var command = context.Session.Build(statements.First());

            Assert.NotNull(command);
            Assert.NotNull(command.CommandText);
            Assert.True(command.CommandText.Length > 0);
            Assert.True(command.Parameters.Count > 0);

            System.Diagnostics.Debug.WriteLine(command.CommandText);
        }
Esempio n. 3
0
        public void Test()
        {
            const string NAME = "Security.User";

            var schema = _accessor.Schema.Parse(NAME, "*, Creator{Name, FullName}", typeof(Zongsoft.Security.Membership.IUser));

            var context = new DataSelectContext(_accessor,
                                                NAME,              //name
                                                schema.EntityType, //entityType
                                                null,              //grouping
                                                Condition.Equal("UserId", 100) | (Condition.Like("Modifier.Name", "Popeye*") & Condition.GreaterThan("Status", 2)),
                                                schema,            //schema
                                                null,              //paging
                                                Sorting.Descending("UserId") + Sorting.Ascending("Creator.Name"));

            var statements = context.Build();

            Assert.NotNull(statements);
            Assert.NotEmpty(statements);

            var command = context.Session.Build(statements.First());

            Assert.NotNull(command);
            Assert.NotNull(command.CommandText);
            Assert.True(command.CommandText.Length > 0);
            Assert.True(command.Parameters.Count > 0);

            System.Diagnostics.Debug.WriteLine(command.CommandText);
        }