public TestConfiguration() { SqlSubject foo, bar; // Add a subject to this configuration with some basic fields. this.Subject(foo = new SqlSubject("Foo") .SqlQuery("SELECT * FROM [Foo]") .FieldId(new Field("Id", typeof(int))) .FieldDefault(new Field("Name", typeof(string))) .Field(new Field("Total", typeof(int))) .Field(new Field("DateCreated", "Date Created", typeof(DateTime))) .Field(new Field("IsArchived", "Is Archived", typeof(bool)))); // Add another subject, this time with a relationship to the first subject. this.Subject(bar = new SqlSubject("Bar") .SqlQuery("SELECT * FROM [Bar]") .FieldId(new Field("Id", typeof(int))) .FieldDefault(new Field("Name", typeof(string))) .Field(new RelationField("FooId", "My Foo", foo)) .Field(new Field("Status", typeof(string)) { List = new FieldList(new object[] { "Pending", "Reviewed", "Active", "Cancelled" }) })); // To ensure ad-hoc relationships can be created dynamically by the user // we need to define how we traverse from Bar to Foo and vice-versa. // (e.g. Search for Bar where Foo.Name = 'Hello World') this.Matrix(bar, foo, "SELECT Bar.Id FromId, Bar.FooId ToId FROM [Bar]") .Matrix(foo, bar, "SELECT Bar.FooId FromId, Bar.Id ToId FROM [Bar]"); }
protected void btnSubmit_Click(object sender, EventArgs e) { int n = SqlSubject.Insert(); if (n == 1) { Response.Write("<script>alert('Subject Uploaded...')</script>"); } }
public ISqlSubject Restore(SubjectDTO dto) { SqlSubject subject = new SqlSubject(); subject.Sql = dto.Sql; subject.DisplayName = dto.DisplayName; foreach (var f in dto.Fields) { subject.Field(_fieldAssembler.Restore(f)); } subject.IdField = subject[dto.IdFieldIndex]; subject.DefaultField = subject[dto.DefaultFieldIndex]; return(subject); }
private static IConfiguration Build() { ISqlSubject user, module, file; return(new MatrixConfiguration() .Subject( user = new SqlSubject("User") .SqlQuery("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 SqlSubject("Module") .SqlQuery("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 SqlSubject("File") .SqlQuery("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")); }