using IBCPackTrack.Models; >>>using System; >>>using System.Data.Entity; >>>using System.Linq; >>> >>>namespace IBCPackTrack.Data >>>{ >>> public class DeliveryHistoryRepository : GenericRepository<DeliveryHistory> >>> { >>> public DeliveryHistoryRepository(DbContext context) >>> : base(context) >>> { >>> >>> } >>> >>> public IQueryable<DeliveryHistory> GetByRouteId(Guid id) >>> { >>> return DbSet.Select(dh => new DeliveryHistory >>> { >>> del_pk = dh.del_pk, >>> del_time = dh.del_time, >>> }); >>> >>> } >>> } >>>}>>>
>>public IQueryable< DeliveryHistory> GetByRouteId(Guid id) >>{ >>return context.DeliveryHistories // The context property that controls access to our data >>.Where(dh => dh.RunSheetDetail.RunSheetHeader.rnh_rtefk == id) // Filter the data by the routes >>.Select(dh => new DeliveryHistorySimple() // Select a subset of the data. If you want all of the DeliveryHistory entity, get rid of the select function >>{ >> del_pk = dh.del_pk, >> del_time = dh.del_time, >> }); >>} >>>
using System; >using System.Configuration; >using System.Data; >using System.Data.Entity; >using System.Linq; > >using IBCPackTrack.Models; >using IBCPackTrack.Data.Configuration; > >namespace IBCPackTrack.Data >{ > class DataContext : DbContext > { > public DbSet<Route> Routes { get; set; } > public DbSet<AirWayBill> AirWayBills { get; set; } > public DbSet<Customer> Customers { get; set; } > public DbSet<DeliveryHistory> DeliveryHistories { get; set; } > public DbSet<DispositionCode> DispositionCodes { get; set;} > public DbSet<RunSheetHeader> RunSheetHeaders { get; set; } > public DbSet<RunSheetDetail> RunSheetDetails { get; set; } > public DbSet<ScanCode> ScanCodes { get; set; } > > public static string ConnectionStringName > { > get > { > if (ConfigurationManager.AppSettings["ConnectionStringName"] != null) > { > return ConfigurationManager.AppSettings["ConnectionStringName"].ToString(); > } > > return "DefaultConnection"; > } > > } > > public DataContext() > : base(nameOrConnectionString: DataContext.ConnectionStringName) > { > // necessary to stop this error: > // Self referencing loop detected for property 'route' with type 'System.Data.Entity.DynamicProxies.Route_ > this.Configuration.LazyLoadingEnabled = false; > } > > protected override void OnModelCreating(DbModelBuilder modelBuilder) > { > modelBuilder.Configurations.Add(new AirWayBillConfiguration()); > modelBuilder.Configurations.Add(new CustomerConfiguration()); > modelBuilder.Configurations.Add(new DeliveryHistoryConfiguration()); > modelBuilder.Configurations.Add(new DispositionCodeConfiguration()); > modelBuilder.Configurations.Add(new RouteConfiguration()); > modelBuilder.Configurations.Add(new RunSheetDetailConfiguration()); > modelBuilder.Configurations.Add(new RunSheetHeaderConfiguration()); > modelBuilder.Configurations.Add(new ScanCodeConfiguration()); > //base.OnModelCreating(modelBuilder); > } > } >}>