How to do JOIN via lambda in the generic repository. I'm following the DDD architecture model.
Example:
public class BaseRepository<T> : IRepositoryBase<T> where T : class
{
private IDbContext _context;
private readonly IDbSet<T> _dbset;
public BaseRepository()
{
var contextManager = ServiceLocator.Current.GetInstance<IContextManager>() as ContextManager;
_context = contextManager.AuditorExternoContext;
_dbset = _context.Set<T>();
}
public virtual void Add(T entity)
{
_dbset.Add(entity);
}
public virtual void Update(T entity)
{
var entry = _context.Entry(entity);
_dbset.Attach(entity);
entry.State = EntityState.Modified;
}
public virtual void Delete(T entity)
{
var entry = _context.Entry(entity);
entry.State = EntityState.Deleted;
}
public T GetById(int id)
{
return _dbset.Find(id);
}
public virtual IEnumerable<T> All()
{
return _dbset.ToList();
}
public virtual IQueryable<T> AllQueryable()
{
return _dbset.AsQueryable();
}
public virtual IEnumerable<T> Find(Expression<Func<T, bool>> predicate)
{
return _dbset.Where(predicate);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!disposing) return;
if (_context == null) return;
_context.Dispose();
_context = null;
}
How do I do join while I'm in a specific class?
public class FaturamentoRepository : BaseRepository<Faturamento>, IAnotacaoRepository
{
}
How do I use BaseRepository
o FaturamentoRepository
?
How to put the inside of faturamentoReposity
.