Filter a datagrid based on a Child datagrid membership

I have a need to filter a datagrid or datalist on miltiple related table memberships. The scenario is like this.

Primary table is Auctions. Each auction is setup internally and has vendors and customers related tables.

Customers should only see auctions they have been added to. Multiple customers can be a part of a single auction.

Vendors should also only see auctions they have been assigned. Multiple vendors can be on a single auction.

I'm not sure how to write this as an expression for the datasource invoke filter.

Hi @joshwilliam,

I am not quite sure I got your requirement but you can check this SO answer that has some complex OData filters by nested children.

If this doesn't help you can probably do the filtering server-side. Create a new partial class for the XXXController (where XXX is the name of your parent entity). Then add a new partial method called OnXXXRead. Then just reassign the items parameter. Here is a quick demo:

public partial class CategoriesController
{
   partial void OnCategoriesRead(ref IQueryable<Category> items)
   {
        items = items.Include(category => category.Products)
                     .Where(category => category.Products.Any());
   }
}