Navigation:  USING THE API > 3.5 WORKING WITH FACILITIES >

3.5.2 Example: Filtering a List of Facilities Using the Facility Collection Class

Previous page Next page
  rev. 2007-12-04        

The following example shows how to filter the list of facilities based on search criteria. In this case, the goal is to filter the facilities to only those which contain “er” in their name.

// Get the "Springfield" Portfolio (ID "01")  from the Data Source "ManagingEnergy Template"

ManagingEnergy.Portfolio portfolio = api.PortfolioManager.GetPortfolio("ManagingEnergy_Template", "01");

 

// Get the list of Facilities contained in the portfolio and fill a FacilityCollection class

FacilityCollection facilities = new FacilityCollection(portfolio.GetFacilities(api));

 

// filter the list to only those facilities containing an 'er' in their name

facilities = facilities.FilterByName(new SearchCriteria("er",SearchCriteria.SearchMethod.Contains));

             

// display the facilities

foreach (ManagingEnergy.Facility facility in facilities)

  Console.WriteLine(facility);        

 

// OUTPUT

1001 - Springfield General Hospital



3.5.2_Example_Filtering_a_List         ©2017 Managing Energy Inc.