> For the complete documentation index, see [llms.txt](https://docs.wirebootstrap.com/orm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.wirebootstrap.com/orm/tables-and-views/toquery.md).

# toQuery

Use the `toQuery` method to transform an entity ORM object into a [WireBootstrap TableQuery](https://docs.wirebootstrap.com/wirebootstrap/reference/wire.data/wire.data.tablequery) object. &#x20;

## TableQuery

The `toQuery` transform allows the functionality of the table query to be used with ORM objects.

The example below transforms the `Categories` ORM query for `CategoryName` into a table query.  It then joins `Categories` with `Products` adding `ProductName` to the list of selected fields.  Last, it executes the query directly against the `Northwind` data source.

```javascript
...

let query = Categories.select(CategoriesField.CategoryName).toQuery();

query.field("ProductName")
    .join("Products", "CategoryId").on("Categories", "CategoryId");

const table: IWireDataTable = await Northwind.execAsync(query);

// print the first row to the console log
console.log(table.select().first());

// log-> { CategoryName: "Dairy Products", ProductName: "Queso Cabrales" }
```
