diff --git a/data_entity/data_entity.entity.inc b/data_entity/data_entity.entity.inc
index a2fd2b4..fe3fa6e 100644
--- a/data_entity/data_entity.entity.inc
+++ b/data_entity/data_entity.entity.inc
@@ -18,15 +18,40 @@
     $this->dataTable = substr($entityType, 5);
   }
 
+    /**
+   * Builds and executes the query for loading.
+   *
+   * @return The results in a Traversable object.
+   */
+  function query($ids, $conditions, $revision_id = FALSE) {
+    // Build the query.
+    
+    $tableinfo = _data_load_table($this->entityInfo['base table']);
+    $database = isset($tableinfo->meta['database']) ? $tableinfo->meta['database'] : FALSE ;
+       
+    if(!empty($database)) {
+      db_set_active($database);
+      }
+    $query = $this->buildQuery($ids, $conditions, $revision_id);
+    $result = $query->execute();
+    db_set_active();
+
+    if (!empty($this->entityInfo['entity class'])) {
+      $result->setFetchMode(PDO::FETCH_CLASS, $this->entityInfo['entity class'], array(array(), $this->entityType));
+    }
+    return $result;
+  }
+
+  
   function load($ids = array(), $conditions = array()) {
     $entities = parent::load($ids, $conditions);
-
+    
     foreach ($entities as $id => $entity) {
       $entity->data_table   = $this->dataTable;
       // Needed until Drupal core fixes this WTF. @see http://drupal.org/node/1042822.
       $entity->entity_type  = $this->entityType;
     }
-
+    
     return $entities;
   }
 }
