Search Results for

    Show / Hide Table of Contents

    Query Categories

    Categories can be retrieved using the ICategoryService or using the Query method or Load method

    var categoryService = client.CreateChannel<ICategoryService>();
    var allCategoriesInATree = categoryService.GetCategories();
    //or using Query
    var allCategoriesInATree2 = client.Query<Category>().ToList();
    

    If you use the Query method or Load method you can also apply filters and include statements

    Filters

    You can filter categories by id

    var category3 = client.Query<Category>().Where(c => c.Id == 3).FirstOrDefault();
    //or using Load
    var category4 = client.Load<Category>(4).FirstOrDefault();
    

    or by parent id

    var childCategories = client.Query<Category>().Where(c => c.ParentId == 3).ToList();
    

    Includes

    You can opt in to populate the IsUsed property.

    var categories = client.Query<Category>().Include(c => c.IsUsed).ToList();
    
    In This Article
    Back to top (c) Meriworks 2002-2022