N
NiceStepUp
Guest
I have an interface and existing code which implements this interface:
public interface IBusinessService<T> where T : class
{
Task Add(T category);
Task Delete(T category);
Task Update(T category);
Task<IEnumerable<T>> GetAll();
Task<T> GetById(int id);
}
Now some id has type of Guid. So I cannot use this method to send Guid id:
var id = Guid.NewGuid()
GetById(id);
So we need that id parameter can be type of Guid. It would be ideal if it is possible:
public interface IBusinessService<T> where T : class
{
/* ... the other code is omitted for the brevity */
Task<T> GetById(Guid or int id );
}
What I thought to implement is to create a new method with parameter type of Guid:
public interface IBusinessService<T> where T : class
{
Task Add(T category);
Task Delete(T category);
Task Update(T category);
Task<IEnumerable<T>> GetAll();
Task<T> GetById(int id);
Task<T> GetById(Guid id);
}
But if I will do this, then I need to edit so many code. So it looks like it is not a good solution.
Is there a way to add another type of id to the interface method GetById without breaking changes?
Continue reading...
public interface IBusinessService<T> where T : class
{
Task Add(T category);
Task Delete(T category);
Task Update(T category);
Task<IEnumerable<T>> GetAll();
Task<T> GetById(int id);
}
Now some id has type of Guid. So I cannot use this method to send Guid id:
var id = Guid.NewGuid()
GetById(id);
So we need that id parameter can be type of Guid. It would be ideal if it is possible:
public interface IBusinessService<T> where T : class
{
/* ... the other code is omitted for the brevity */
Task<T> GetById(Guid or int id );
}
What I thought to implement is to create a new method with parameter type of Guid:
public interface IBusinessService<T> where T : class
{
Task Add(T category);
Task Delete(T category);
Task Update(T category);
Task<IEnumerable<T>> GetAll();
Task<T> GetById(int id);
Task<T> GetById(Guid id);
}
But if I will do this, then I need to edit so many code. So it looks like it is not a good solution.
Is there a way to add another type of id to the interface method GetById without breaking changes?
Continue reading...