Get a collection of child positions for a given parent position
If Position and Position() in your code is the same and you supposed to call GetChildPos instead of GetChildRows in the inner loop then your code can be significantly simplified:

var someVariable = GetChildPos(posId).ToList();

public IEnumerable&lt;Position&gt; GetChildPos(int posId)
{
    yield return serviceRepo.Position.GetById(posId);

    foreach (var pos in serviceRepo.Position().GetAll()
                                              .Where(x =&gt; x.ParentPosId == posId)
                                              .SelectMany(x =&gt; GetChildPos(x.Id)))
    {
        yield return pos;
    }
}


Also it can improve performance because in your original code you do this instructions

serviceRepo.Position().GetAll().Where(x =&gt; x.ParentPosId == posId)


two times that can cause slowing down if some method in this chain is not lazy and executes heavy code even for Any().