My unit of work is basically set up as this tutorial, with minor additions:
I want to know how to do a join on two tables. I tried adding this to GenericRepository, but as you may guess my Linq knowledge is dubious.
public virtual IQueryable AsQueryable()
{
IQueryable<TEntity> query = dbSet;
return query;
}
And then doing
// uow is defined as new UnitOfWork() on class instantiation
var data = from x in uow.MyRepository.AsQueryable()
join y in uow.MyOtherRepository.AsQueryable()
on x.prop1 equals y.prop2
But it wont let me access properties within my table. I basically need a way of returning the table as a queriable entity (I think)
Ironically I worked it out straight after posting. Result, for those who find the same issue:
var entity1 = uow.repo1.Get();
var entity2 = uow.repo2.Get();
var res = (from x in entity1
join y in entity2
on x.propToJoin equals y.propToJoin
select new
{
test = x.propertyToGrab
}).ToList();