Я сделал свои репозитории для показа IQuerables через DbContext. Обертка DbContext с UnitOfWork выглядит следующим образом
Моя база репозитория выглядит так
/// <summary>
/// Gets the query.
/// </summary>
/// <returns></returns>
public IQueryable<TEntity> GetQuery()
{
return this.UnitOfWork.GetQuery<TEntity>();
}
/// <summary>
/// Loads the type.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public IQueryable<T> LoadType<T>() where T : class
{
return this.UnitOfWork.GetQuery<T>();
}
моя единица работы выполняется здесь
/// <summary>
/// Gets the query.
/// </summary>
/// <typeparam name="TEntity">The type of the entity.</typeparam>
/// <returns></returns>
public IQueryable<TEntity> GetQuery<TEntity>() where TEntity:class
{
return this.DbContext.Set<TEntity>();
}
Изменения в моем запросе следующие:
var result = from cc in GetQuery()
join bb in LoadType<PurchaseOrderLineItem>() on cc.Id equals bb.PurchaseOrderId
where cc.Id == purchaseOrder.Id && bb.Total > 50
select bb;