Im following the tutorial for EF6 along with the PlutoContext examples
I have generated the default code with an IRepository etc and then my Products class implements that class + my IProductRepository for any additional methods. This is what i have so far
public class ProductRepository : IRepository<Product>, IProductRepository
{
private readonly SomeContext _context;
public ProductRepository(SomeContext context) : base(context)
{
_context = context;
}
}
Most classes dont have the _context available but i have a method where i need to Join the products with the categories as at present i only get the products and the integer value of category where i would like to retrieve the name of the category.
Would it be correct to use the _context as above in my method and then establish that relationship with categories? Something like
Public IEnumerable<Product> GetProdsAndCats()
{
var pc = from p in products
join pp in _context.Category on p.CatId equals pp.Id
select p;
.....
}
The syntax maybe a little off but as you can see i am using the _context module wide variable to join the tables.
Is this the correct approach?