I have some tables which stores the file’s data, e.g TabA, TabB, TabC, … TabX. Each of them has the same column FileTypeID.
For each table I need to use the extension method to get the rows depending of the condition of the FileTypeID column. To do so, I have an extension method like that:
public static class FilesTab_Extenders
{
public static IList<TabA> GetSpecificFiles(this EntityCollection<TabA> mc)
{
///
}
}
but, I don’t want mindlessly clone the same code for the rest of tables. The only difference will be the parameter – this EntityCollection<TabB>, this EntityCollection<TabC> etc. So, is it somehow possible to make the universal code for that scenario ?
To me the easiest way to do this would be to use an interface. You would then have your partial classes implement this interface and use it in your extention method:
Now you would create partial class files for each of your TabA, TabB, TabC, … TabX that follow this template:
Finally your extention method would be changed to look like this: