Created
March 20, 2012 20:45
-
-
Save mikebosco/2141088 to your computer and use it in GitHub Desktop.
It's dangerous to go alone, etc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Text; | |
| using Dev.Data; | |
| namespace UBoundTools.Database.LMP | |
| { | |
| public class DeterminePath | |
| { | |
| public List<string> SchoolsFromAreaList(string area, string edu) | |
| { | |
| // Define the ID of the entity for supporting queries | |
| int eduIdentityBasement = Database.ProgramData.SubQuery.getEduIDBasement(edu); | |
| int eduIdentity = Database.ProgramData.SubQuery.getEduID(edu); | |
| int areaID = Database.ProgramData.SubQuery.getAOIID(area); | |
| // Query the database for schools with the given criteria | |
| var query = new DevDB().Select | |
| .From<School>() | |
| .InnerJoin<Program>() | |
| .InnerJoin<Degree>() | |
| .InnerJoin<DegreeCategory>() | |
| .Where(ProgramsTable.AreaOfInterestColumn).IsEqualTo(areaID) | |
| .And(ProgramsTable.ActiveColumn).IsEqualTo(true) | |
| .And(SchoolsTable.SchoolCodeColumn).IsNotNull() | |
| .And(DegreeCategoriesTable.DegreeCategoryIDColumn).IsLessThanOrEqualTo(eduIdentity) | |
| .And(DegreeCategoriesTable.DegreeCategoryIDColumn).IsGreaterThanOrEqualTo(eduIdentityBasement) | |
| .ExecuteTypedList<School>(); | |
| //if we got any results, iterate through them and return a list of strings containing the schoolcode | |
| if (query.Count() > 0) | |
| { | |
| List<string> returnList = new List<string>(); | |
| foreach (var x in query) | |
| { | |
| if (!returnList.Contains(x.SchoolCode)) | |
| { | |
| returnList.Add(x.SchoolCode); | |
| } | |
| } | |
| return returnList; | |
| } | |
| return null; | |
| } | |
| public List<string> SchoolsFromProductList(string program, string edu) | |
| { | |
| // Define the ID of the entity for supporting queries | |
| int eduIdentityBasement = Database.ProgramData.SubQuery.getEduIDBasement(edu); | |
| int eduIdentity = Database.ProgramData.SubQuery.getEduID(edu); | |
| int progCode = Database.ProgramData.SubQuery.getProductID(program); | |
| // Query the database for schools with the given criteria | |
| var query = new DevDB().Select | |
| .From<School>() | |
| .InnerJoin<Program>() | |
| .InnerJoin<Degree>() | |
| .InnerJoin<DegreeCategory>() | |
| .Where(ProgramsTable.ProgramCodeColumn).IsEqualTo(progCode) | |
| .And(ProgramsTable.ActiveColumn).IsEqualTo(true) | |
| .And(SchoolsTable.SchoolCodeColumn).IsNotNull() | |
| .And(DegreeCategoriesTable.DegreeCategoryIDColumn).IsLessThanOrEqualTo(eduIdentity) | |
| .And(DegreeCategoriesTable.DegreeCategoryIDColumn).IsGreaterThanOrEqualTo(eduIdentityBasement) | |
| .ExecuteTypedList<School>(); | |
| //if we got any results, iterate through them and return a list of strings containing the schoolcode | |
| if (query.Count() > 0) | |
| { | |
| List<string> returnList = new List<string>(); | |
| foreach (var x in query) | |
| { | |
| if (!returnList.Contains(x.SchoolCode)) | |
| { | |
| returnList.Add(x.SchoolCode); | |
| } | |
| } | |
| return returnList; | |
| } | |
| return null; | |
| } | |
| public List<string> SchoolsFromProgramCategory(string category, string edu) | |
| { | |
| int eduIdentityBasement = Database.ProgramData.SubQuery.getEduIDBasement(edu); | |
| int eduIdentity = Database.ProgramData.SubQuery.getEduID(edu); | |
| int categoryID = Database.ProgramData.SubQuery.getCategoryID(category); | |
| //Linq to SQL(Subsonic) | |
| var db = new DevDB(); | |
| var query = | |
| (from s in School.All() | |
| join p in db.Programs on s.SchoolID equals p.SchoolID | |
| join d in db.Degrees on p.DegreeID equals d.DegreeID | |
| join pc in db.ProgramCategories on p.ProgramCategory equals pc.CategoryID | |
| where s.SchoolCode != null | |
| && s.Active == true | |
| && p.ProgramCategory == categoryID | |
| && d.DegreeCategoryID <= eduIdentity | |
| && d.DegreeCategoryID >= eduIdentityBasement | |
| && pc.CategoryID == categoryID | |
| select s); | |
| //if we got any results, iterate through them and return a list of strings containing the schoolcode | |
| if (query.Count() > 0) | |
| { | |
| List<string> returnList = new List<string>(); | |
| foreach (var x in query) | |
| { | |
| if (!returnList.Contains(x.SchoolCode)) | |
| { | |
| returnList.Add(x.SchoolCode); | |
| } | |
| } | |
| return returnList; | |
| } | |
| return null; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment