---
title: "How to select from multiple tables, map to 1 object"  
description: "How to select from multiple tables, map to 1 object"  
author: "Revati S Misra"  
published: 2023-09-05  
updated: 2023-09-06  
canonical: https://www.mindstick.com/forum/159850/how-to-select-from-multiple-tables-map-to-1-object  
category: "asp.net core"  
tags: ["c#", "database table", "asp.net core"]  
reading_time: 2 minutes  

---

# How to select from multiple tables, map to 1 object

How to [select](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) from [multiple tables](https://www.mindstick.com/forum/159848/how-to-get-multiple-tables-using-entity-framework-core), [map](https://yourviews.mindstick.com/view/81351/nepal-parliament-s-approves-new-controversial-map-india-rejects-it-but) to 1 object

## Replies

### Reply by Aryan Kumar

To select from [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) [tables](https://www.mindstick.com/articles/336597/introduction-of-html-tables-for-web-development) and map them to an object, you can use the Join and the Select operator. The `Join` operator join the tables and the `Select` operator associates the rows of the joined tables to an object.

The join operator has the same syntax as previously described. The syntax for the select operator is:

```plaintext
select new { column1, column2 }
```

where `column1` and `column2` are the names of the columns that you want to map to the object.

For example, the following code joins the tables `Customers` and `Orders` and maps the rows to a single object named `CustomerOrder`:

```plaintext
from customer in Customers
join order in Orders on customer.Id equals order.CustomerId
select new CustomerOrder { customer.Name, order.OrderId }
```

This code returns a new table that containing the names of all the customers and the IDs for all the orders. Each row in the new table will be an object of the `CustomerOrder` type.

You can also use the `Select` operator to map the rows of the joined tables to another object. For example, the following code joins the `Customers`, `Orders`, and `Products` tables and maps the rows to a single object called `CustomerOrderProduct`:

```plaintext
from customer in Customers
join order in Orders on customer.Id equals order.CustomerId
join product in Products on order.ProductId equals product.Id
select new CustomerOrderProduct { customer.Name, order.OrderId, product.Name }
```

This code returns a new table containing the names of all the customers, their order IDs, and the names of all the products they ordered. Each row of the table is an object of the `CustomerOrderProduct` type.


---

Original Source: https://www.mindstick.com/forum/159850/how-to-select-from-multiple-tables-map-to-1-object

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
