// needed for reflection /// <summary> /// Retrieves a list of employee events. /// </summary> /// <param name="web">the web containing the events list</param> /// <returns></returns> public static IList <SpecialEvent> FindEmployeeEvents(SPWeb web) { // Create an instance of the FindByAudience query that filters by employee. var queryEmployeeEvents = new FindEventsByAudience("Employee"); // Use the generic Fetch method to bind to the SpecialEvent class. return(queryEmployeeEvents.Fetch <SpecialEvent>(web)); }
/// <summary> /// This static method shows how this class could be used in an application. /// </summary> public static void Test() { // Create an instance of the query that finds events for the "Employee" audience. var queryEmployeeEvents = new FindEventsByAudience("Employee"); // Create a second instance that finds events for the "VIP" audience. var queryVIPEvents = new FindEventsByAudience("VIP"); // Open a web and execute both instances. using (var web = new SPSite("http://localhost").OpenWeb()) { // Get the list of employee events. var employeeEvents = queryEmployeeEvents.Fetch(web); // Get the list of vip events and extend the search to include all subwebs. var vipEvents = queryVIPEvents.Fetch(web, CAML.QueryScope.Recursive); // ... custom code omitted to work with the resulting list items } }