Hello im trying to build a generic repository on top of linq2sql. I have a interface for the generic repository:
public interface IRepository<T> where T : class
{
void Update(T entity);
T CreateInstance();
void Delete(int id);
T Get(int id);
List<T> GetAll();
List<T> GetAll(Func<T, bool> expr);
}
I have an implementation of this too. Now i have made a connection through linq2sql to my database and gotten 2 classes, "Car" and "House", now i want to make a specialized repository for car:
public interface ICarRepository<Car> : IRepository<Car>
{
}
Now i get the error that: The type 'Car' must be a reference type in order to use it as parameter 'T' in the generic type or method 'GenericRepository.Repository.IRepository<T>'
How come i get that error, this is the signature of the "Car" class:
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Car")]
public partial class Car : INotifyPropertyChanging, INotifyPropertyChanged
{...}