queries and filters on parameters - Envivo-Software/Envivo.Fresnel GitHub Wiki

Queries & Filters on Parameters

To use Query/Filters with method parameters, apply the FilterQuerySpecificationAttribute to the parameter in question, like so:

/// <summary>
/// An entry within an Order
/// </summary>
public class ShoppingCartItem : IEntity
{
    ... other members here...

    /// <summary>
    /// The categories that this product is assigned to
    /// </summary>
    [Relationship(RelationshipType.Has)]
    public ICollection<Category> Categories { get; set; }

    /// <summary>
    /// Assigns the selected Categories to this Product
    /// </summary>
    /// <param name="categories"></param>
    public void AssignCategories(
        [FilterQuerySpecification(typeof(CategoryQuerySpecification))] //👈
        IEnumerable<Category> categories)
    {
        foreach (var category in categories)
        {
            this.Categories.Add(category);
        }
    }

}

Clicking the Method button opens a selection dialog, showing the results of the query:

In the example above, the target property is a collection, so the dialog allows multiple items to be selected.

⚠️ **GitHub.com Fallback** ⚠️