views:

128

answers:

1

I feel like this should be easy, but I don't see any way to do it.

I'm using ASP.NET Dynamic Data with Linq to SQL. I've got a table with an Association to the Technician table. The Parent Property is TechAssignment, and on the web form I'm using a DynamicField to display it.

This works fine really, it correctly sees it as a ForeignKeyField and uses that template to give me a dropdown with a list of techs from the Technicians table.

The only problem is that it gives me a list of ALL the technicians, when there are quite a few who are inactive. How can I tell Dynamic Data to filter out inactive technicians so they can't be selected?

A: 

LINQ to SQL generates partial classes.

  1. Add a new property (copy from the other foreign key property)
  2. Apply the filter in the get (either by LINQ2SQL or filtering the original property)
  3. Bind to that property

Example UnapprovedContacts in Association table

public partial class Association
{
    public IList<Contact> UnapprovedContacts
    {
        get
        {
            return Contacts.Where(c => !c.IsApproved).ToList();
        }
    }
}
Peter Gfader