I recently worked on a web part which processes test scores for students. Test scores are stored in a list, organized by course and by user. The web part should retrieve the test scores for the logged in user, then the user’s score for each course. A previous implementation used a view, My Scores, which showed test scores for the logged in user by defining a filter, “Username is equal to [Me]”.
It occurred to me to retrieve a user’s test score for a course by performing a CAML search on the My Scores view. Typically, when searching a list using a CAML query, you can do something like this:
SPQuery query = new SPQuery();
query.Query = <query for course>;
results = list.GetItems(query); |
There is an overloaded version of the SPQuery constructor that takes an SPView. Additionally, SPList.GetItems has an overloaded version that also takes an SPView. Given the availability of the SPView parameter, I was tempted to perform the CAML search on the My Scores view by doing the following: Continue reading Considerations When Using View in CAML Search