Hi svibuk,
Refer the below sample code. As you want to display only few columns you have to do like below. So that you can fetch the required columns. You can use alias name for these columns but not compulsory. So change the code as per your table structure and column name.
Using alias name
var PList = from data in db.Customers
join order in db.Orders on data.CustomerID equals order.CustomerID
where data.CustomerID == Id
select new
{
Id = data.CustomerID,
CompanyName = data.CompanyName,
ContactName = data.ContactName,
Title = data.ContactTitle,
Address = data.Address,
City = data.City,
Region = data.Region,
PostalCode = data.PostalCode,
Country = data.Country,
Phone = data.Phone,
Fax = data.Fax,
OrderID = order.OrderID,
EmployeeID = order.EmployeeID,
OrderDate = order.OrderDate,
Required = order.RequiredDate,
Shipped = order.ShippedDate,
ShipVia = order.ShipVia,
Freight = order.Freight,
ShipName = order.ShipName,
ShipAddress = order.ShipAddress,
ShipCity = order.ShipCity,
ShipRegion = order.ShipRegion,
ShipPostalCode = order.ShipPostalCode,
ShipCountry = order.ShipCountry
};
Without using alias name
var PList = from data in db.Customers
join order in db.Orders on data.CustomerID equals order.CustomerID
where data.CustomerID == Id
select new
{
data.CustomerID,
data.CompanyName,
data.ContactName,
data.ContactTitle,
data.Address,
data.City,
data.Region,
data.PostalCode,
data.Country,
data.Phone,
data.Fax,
order.OrderID,
order.EmployeeID,
order.OrderDate,
order.RequiredDate,
order.ShippedDate,
order.ShipVia,
order.Freight,
order.ShipName,
order.ShipAddress,
order.ShipCity,
order.ShipRegion,
order.ShipPostalCode,
order.ShipCountry
};