public List <Company> Search() { return(_context .Companies .Select(company => ModelMapperService.MapFromModel(company)) .ToList()); }
public List <RecursiveStack> RecursiveSearch(int companyId) { return(_context.RecursiveStackModel.FromSqlRaw( @" WITH RECURSIVE rec(id, name, parent_id, depth, path) AS ( SELECT S.id, S.name, S.parent_id, 1::INT AS depth, S.id::TEXT AS path FROM stack AS S WHERE S.company_id = {0} AND parent_id IS NULL UNION ALL SELECT SR.id, SR.name, SR.parent_id, R.depth + 1 AS depth, (R.path || '>' || SR.id::TEXT) FROM rec AS R, stack AS SR WHERE SR.parent_id = R.id ) SELECT * FROM rec;", companyId ) .Select(model => ModelMapperService.MapFromModel(model)) .ToList()); }
public Company Get(int id) { return(ModelMapperService.MapFromModel( _context.Companies.Select(company => company).First(company => company.Id.Equals(id)) )); }