public List<StudentRecord> Execute()
        {
            DynamicQueryStatement dqs = ToDynamicQueryStatement();

            try
            {
                StudentsContext context = new StudentsContext();

                List<StudentRecord> students = context.StudentRecords.Where(dqs.Query, dqs.Parms)
                    .OrderBy(x => x.LastName + x.FirstName + x.MiddleInitial)
                    .ToList();

                return students;
            }
            catch (Exception ex)
            {
                AnvilExceptionCollector ec = new AnvilExceptionCollector("Could not get students from database");
                ec.Add(ex);
                ec.Add(dqs.Query);
                throw ec.ToException();

            }
        }
Beispiel #2
0
        public static List<StudentRecord> GetStudents(DynamicQueryStatement dqs)
        {
            try
            {
                StudentsContext db = new StudentsContext();

                return db.StudentRecords.Where(dqs.Query, dqs.Parms)
                    .OrderBy( x => x.LastName + x.FirstName + x.MiddleInitial)
                    .ToList();
            }
            catch (Exception ex)
            {
                throw new Exception("Could not get students from database", ex);
            }
        }