/// <summary> /// Returns a single object with a primary key of the provided id /// </summary> /// <remarks>Asynchronous</remarks> /// <param name="id">The primary key of the object to fetch</param> /// <returns>A single object with the provided primary key or null</returns> public async Task <TEntity> GetAsync(int id, bool option = false) { var entity = await Context.Set <TEntity>().FindAsync(id); if (!option) { Context.Entry(entity).State = EntityState.Detached; } return(entity); // return await this.entities.FindAsync(id); }
/// <summary> /// The contructor requires an open DataContext to work with /// </summary> /// <param name="context">An open DataContext</param> public RepositoryMachineMk2(MachineContext context) { this.Context = context; try { this.Entities = context.Set <TEntity>(); } catch { this.Queries = context.Query <TEntity>(); } }
/// <summary> /// The contructor requires an open DataContext to work with /// </summary> /// <param name="context">An open DataContext</param> public RepositoryMachine(MachineContext context) { this.Context = context; this.Entities = context.Set <TEntity>(); }