I have created this generic method
public IEnumerable GetByID(IEnumerable source, int id) where T : IFields
{
return source.Where(x
The obvious reason for this error message is that Items
doesn't implement IFields
.
In other words, your Items
type need to have this:
public class Items : IFields
^-----^
If you don't have this, then Items
is not a valid type for your GetByID<T>
method since it doesn't implement this interface.
This is true even if the Items
type just happens to have the right members. Unless you've explicitly stated that those members also implement the interface, by doing what I showed above, then that is not enough. So even if your Items
type have the id
property, you still have to state explicitly that the type implements the interface.