I have a method that counts the number of Contacts each Supplier, Customer and Manufacturer has (this is a scenario to try make explaining easier!)
The models are all created by Linq to SQL classes. Each Supplier, Customer and Manufacturer may have one or more Contacts
public int CountContacts<TModel>(TModel entity) where TModel : class
{
return entity.Contacts.Count();
}
The above of course doesnt work, because the 'entity' is generic and doesnt know whether it has the property 'Contacts'. Can someone help with how to achieve this?