return DBSet.Where(dh => dh.RunSheetDetail.RunSheetHeader.rnh_rtefk == id);compiles successfully, thanks.
public ActionResult Get(Guid id) { DeliveryHistoryViewModel vm = new DeliveryHistoryViewModel(); vm.DeliveryHistory = this._unit.DeliveryHistories.GetByRouteId(id); // error is here if (vm.DeliveryHistory != null) { return View("DeliveryHistory", vm); } return View("NotFound"); }The error is:
'IBCPackTrack.Data.IRepository<IBCPackTrack.Models.DeliveryHistory>' does not contain a definition for 'GetByRouteId' and no extension method 'GetByRouteId' accepting a first argument of type 'IBCPackTrack.Data.IRepository<IBCPackTrack.Models.DeliveryHistory>' could be found (are you missing a using directive or an assembly reference?)
I guess this has something to do with my ApplicationUnit definition:using System; using IBCPackTrack.Models; namespace IBCPackTrack.Data { public class ApplicationUnit : IDisposable { private DataContext _context = new DataContext(); private IRepository<AirWayBill> _airwaybills = null; private IRepository<Customer> _customers = null; private IRepository<DeliveryHistory> _deliveryhistories = null; private IRepository<DispositionCode> _dispositioncodes = null; private IRepository<Route> _routes = null; private IRepository<RunSheetDetail> _runsheetdetails = null; private IRepository<RunSheetHeader> _runsheetheaders = null; private IRepository<ScanCode> _scancodes = null; // code removed for this posting public IRepository<DeliveryHistory> DeliveryHistories { get { if (this._deliveryhistories == null) { this._deliveryhistories = new GenericRepository<DeliveryHistory>(this._context); } return this._deliveryhistories; } } } }My IRepository is defined like this:
using System; using System.Linq; namespace IBCPackTrack.Data { public interface IRepository<T> where T : class { IQueryable<T> GetAll(); T GetById(Guid id); void Add(T entity); void Update(T entity); void Delete(T entity); void Delete(Guid id); void Detach(T entity); } }I guess I need to do some special kind of repository for my DeliveryHistories, is that right?