I would like to implement a interface and repository pattern. My different repositories can have type data types,
First one is (String-int, char-long)
Second one is (Char-double, double-string). Pattern keeps going, we have around 50 different methods.We are changing our interface/repositories to another database system, etc.
How would I edit the edit the interface below, to allow different data types? Thanks,
public interface ITransactionRepository
{
void SearchTransactionbyCategoryCustomerId(Category, CustomerId ); // what should I write here?
void SearchTransactionbyProductDepartment(Product, Department);
......
}
public class TransactionRepository1: IRepository
{
void SearchTransactionbyCategoryCustomerId(string Category, int CustomerId);
void SearchTransactionbyProductDepartment(char Product, long Department);
......
}
public class TransactionRepository2: IRepository
{
void SearchTransactionbyCategoryCustomerId(char Category, double CustomerId);
void SearchTransactionbyProductDepartment(double Product, string Department);
......
}
where T: string, char(which you cannot), how would those methods look like?if T is string...?IRepositoryreally beITransactionRepositoryor is something missing?Product) withProducts,chars, anddoubles. Couldn't you standardize that rather than worry about all the combinations?