Return the first n Entities for the set.
 If count is 1 it returns the single entity, otherwise its an array of entities
 @return [OData::EntitySet]
435460
def first(count = 1)
      query = OData::Query.new(self).limit(count)
      result = service.execute(query)
      entities = service.find_entities(result)
      res = count == 1 ? single_entity_from_xml(entities) : multiple_entities_from_xml(entities)
      res
    end
149349
protected List fetch()
    {
        EntityMetadata metadata = getEntityMetadata();
        Client client = persistenceDelegeator.getClient(metadata);
        List results = isRelational(metadata) ? recursivelyPopulateEntities(metadata, client) : populateEntities(
                metadata, client);
        return results;
    }
854055
public function getData()
    {
        $data = [];

        // Paginator is better if the query uses ManyToMany associations
        $result = $this->qb->getMaxResults() !== NULL || $this->qb->getFirstResult() !== NULL
            ? new Paginator($this->getQuery())
            : $this->qb->getQuery()->getResult();

        foreach ($result as $item) {
            // Return only entity itself
            $data[] = is_array($item)
                ? $item[0]
                : $item;
        }

        return $data;
    }
669212
public function count()
    {
        if ($this->isInitialized()) {
            return $this->collection->count();
        }

        // Return cached result in case count query was already executed
        if ($this->count !== null) {
            return $this->count;
        }

        return $this->count = $this->entityPersister->count($this->criteria);
    }
1341530
private function getTotalNumberOfEntities($entity, $startOffset)
    {
        $objectManager = $this->getObjectManager($entity);
        $repository = $objectManager->getRepository($entity);

        if ($repository instanceof DocumentRepository) {
            $totalSize = $repository->createQueryBuilder()
                ->getQuery()
                ->count();
        } else {
            $dataStoreMetadata = $objectManager->getClassMetadata($entity);

            $identifierFieldNames = $dataStoreMetadata->getIdentifierFieldNames();

            if (!count($identifierFieldNames)) {
                throw new \Exception(sprintf('No primary key found for entity %s', $entity));
            }

            $countableColumn = reset($identifierFieldNames);

            /** @var EntityRepository $repository */
            $totalSize = $repository->createQueryBuilder('size')
                ->select(sprintf('count(size.%s)', $countableColumn))
                ->getQuery()
                ->getSingleScalarResult();
        }

        return $totalSize - $startOffset;
    }
893122
def count
      raise OData::NotSupportedError.new("You cannot call both the `links` method and the `count` method in the same query.") if @links_navigation_property
      raise OData::NotSupportedError.new("You cannot call both the `select` method and the `count` method in the same query.") unless @select.empty?

      @count = true
      self
    end
770796
def find_entities(results)
      document = ::Nokogiri::XML(results.body)
      document.remove_namespaces!
      document.xpath('//entry')
    end
1147653
def first(opts={})
      sq = Tripod::SparqlQuery.new(self.as_query(opts))
      first_sparql = sq.as_first_query_str
      self.resource_class._resources_from_sparql(first_sparql).first
    end
1224536
public List<Entity<EntityMappings<T>>> getAllEntity()
   {
      List<Entity<EntityMappings<T>>> list = new ArrayList<Entity<EntityMappings<T>>>();
      List<Node> nodeList = childNode.get("entity");
      for(Node node: nodeList)
      {
         Entity<EntityMappings<T>>  type = new EntityImpl<EntityMappings<T>>(this, "entity", childNode, node);
         list.add(type);
      }
      return list;
   }
162728
def all_entities(self, is_active=True):
        
        return self.get_all_entities(return_models=True, is_active=is_active)
476935
def first(self, limit=1, columns=None):
        
        if not columns:
            columns = ['*']

        results = self.take(limit).get(columns)

        if len(results) > 0:
            return results[0]

        return
51319
def filtany(entities, **kw):
  
  ret = set()
  for k,v in kw.items():
    for entity in entities:
      if getattr(entity, k)() == v:
        ret.add(entity)
  return ret
465646
public <E> List<E> find(Class<E> entityClass, Object... primaryKeys)
    {
        List<E> entities = new ArrayList<E>();
        if (primaryKeys == null)
        {
            return entities;
        }
        Set<Object> pKeys = new HashSet<Object>(Arrays.asList(primaryKeys));
        for (Object primaryKey : pKeys)
        {
            E e = find(entityClass, primaryKey);
            if (e != null)
            {
                entities.add(e);
            }
        }
        return entities;
    }
905651
def filtfirst(entities, **kw):
  """"""
  ret = sorted(filtany(entities, **kw), key=lambda x:x.id())
  if not ret:
    raise ValueError('No result')
  return ret[0]
823687
def first(n = nil)
      occurrences = enumerate_occurrences(start_time).take(n || 1)
      n.nil? ? occurrences.first : occurrences
    end
314861
function getEntities(callback) {
    self.get(filter, fields, null, page, sort, function(error, entities, pagination) {
      if (error) return callback(error);

      allEntities = allEntities.concat(entities);

      if (page < pagination.pages - 1) {

        // There are other pages
        // Get next page
        page++;
        getEntities(callback);

      } else {

        // No more pages
        // End it
        callback(null);
      }
    });
  }
511015
def list(self, entityid=None):
		
		params = {}
		if entityid:
			params['name'] = entityid
		data = self._http_req('connections',params=params)
		entities = data['decoded']['connections']

		# hash key will be string (damned json), so convert to integer
		entities = {int(k): v for k, v in entities.items()}
		entities_list = sorted(entities.items(), key=lambda x: x[0])
		entities = OrderedDict(entities_list)
		return entities