Exemple #1
0
        private static IConfiguration Build()
        {
            ISubject user, module, file;

            return new ConfigurationImpl()
                .Subject(
                    user = new Subject("User")
                        .Sql("SELECT * FROM Users")
                        .FieldId(new Field("Id", typeof(Guid)))
                        .FieldDefault(new Field("Name", typeof(string)) { List = new FieldList() { Source = "SELECT Id, Name AS Value FROM Users", Type = FieldListType.Suggested } })
                        .Field(new Field("RegistrationCode", "Registration Code", typeof(string))))
                .Subject(
                    module = new Subject("Module")
                        .Sql("SELECT * FROM tblModule")
                        .FieldId(new Field("module_id", typeof(int)))
                        .FieldDefault(new Field("module_name", "Name", typeof(string)) { List = new FieldList() { Source = "SELECT module_id Id, module_name AS Value FROM tblModule", Type = FieldListType.Suggested } })
                        .Field(new Field("module_software", "Software", typeof(string)) { List = new FieldList() { Source = "SELECT DISTINCT module_software FROM tblModule", Type = FieldListType.Limited } }))
                .Subject(
                    file = new Subject("File")
                        .Sql("SELECT * FROM tblFile")
                        .FieldId(new Field("File_id", typeof(int)))
                        .Field(new RelationField("File_Module", "Module", module))
                        .FieldDefault(new Field("File_Description", "Description", typeof(string)))
                        .Field(new Field("File_Type", "Type", typeof(string)) { List = new FieldList() { Source = "SELECT DISTINCT File_Type FROM tblFile", Type = FieldListType.Limited } })
                        .Field(new Field("File_filename", "Filename", typeof(string)))
                        .Field(new Field("File_Version", "Version", typeof(string)))
                        .Field(new Field("File_Comment", "Comment", typeof(string)))
                        .Field(new Field("File_NotesURL", "Notes URL", typeof(string)))
                        .Field(new Field("File_EULA", "EULA URL", typeof(string))))

                .Matrix(user, module,
                    "SELECT u.Id FromId, am.Allowed_Module ToId FROM Users u INNER JOIN UserProducts up ON u.Id = up.UserId INNER JOIN tblAllowedModules am ON up.OldCouncilId = am.Allowed_Council",
                    "Search for modules that are assigned to a user")
                .Matrix(user, file,
                    "SELECT u.Id FromId, f.File_Id ToId FROM Users u INNER JOIN UserProducts up ON u.Id = up.UserId INNER JOIN tblAllowedModules am ON up.OldCouncilId = am.Allowed_Council INNER JOIN tblFile f ON f.File_Module = am.Allowed_Module",
                    "Search for files that are assigned to a user")
                .Matrix(module, user,
                    "SELECT u.Id FromId, am.Allowed_Module ToId FROM Users u INNER JOIN UserProducts up ON u.Id = up.UserId INNER JOIN tblAllowedModules am ON up.OldCouncilId = am.Allowed_Council",
                    "Search for users that are assigned to a module")
                .Matrix(module, file,
                    "SELECT File_Module FromId, File_Id ToId FROM tblFile",
                    "Search for files that are part of a module")
                .Matrix(file, user,
                    "SELECT f.File_Id FromId, u.Id ToId FROM Users u INNER JOIN UserProducts up ON u.Id = up.UserId INNER JOIN tblAllowedModules am ON up.OldCouncilId = am.Allowed_Council INNER JOIN tblFile f ON f.File_Module = am.Allowed_Module",
                    "Search for users that are assigned to a file")
                .Matrix(file, module,
                    "SELECT File_Id FromId, File_Module ToId FROM tblFile",
                    "Search for modules that contain a file");
        }
        public void Fluent_config_matrix()
        {
            ISubject s1, s2;
            var config = new ConfigurationImpl();
            config
                .Subject(s1 = new Subject()
                    .Field(new Field("column1", "display1", typeof(string))))
                .Subject(s2 = new Subject()
                    .Field(new RelationField("column1", "display1", typeof(Guid), s1)));

            MatrixNode n;
            n = config[s1, s1];
            n = config[s1, s2];
            n = config[s2, s1];
            n = config[s2, s2];
        }
        public void Fluent_config_complex_field()
        {
            ISubject s1, s2;
            var config = new ConfigurationImpl();
            config
                .Subject(s1 = new Subject()
                    .Field(new Field("column1", "display1", typeof(string))))
                .Subject(s2 = new Subject()
                    .Field(new RelationField("column1", "display1", typeof(Guid), s1)));

            Assert.AreEqual(config.Count, 2);
            Assert.AreEqual(s2.Count, 1);
            Assert.AreEqual(s2[0].GetType(), typeof(RelationField));

            RelationField f1 = (RelationField)s2[0];
            Assert.AreEqual(f1.SourceName, "column1");
            Assert.AreEqual(f1.DisplayName, "display1");
            Assert.AreEqual(f1.DataType, typeof(Guid));
        }
        public void Fluent_id_field()
        {
            IField f;
            var subject = new Subject()
                .FieldId(f = new Field("column1", typeof(string)));

            Assert.AreSame(f, subject.IdField);
        }
        public void Fluent_default_field()
        {
            IField f;
            var subject = new Subject()
                .FieldDefault(f = new Field("column1", typeof(string)));

            Assert.AreSame(f, subject.DefaultField);
        }