I am using entity framework and Linq to fetch the data.
I have to tables Product and Order Detail. In Order detail table I have order Id and Product Id. While displaying data in gridview I am fetching data from order detail table. But I don't want to show Product Id in the grid. Instead of that I want to show related product name from product table.
I have EDMX file which has created two classes Product and Order detail. I am using LINQ to fetch data from Order details table. How can I get Product Name of related product ID. Method return type can not be Order detail. It gives me below error.
Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Collections.Generic.List
Amit JoshiPosted Apr 17, 2015, 11:48 AM
Amit JoshiPosted Apr 17, 2015, 9:53 AM
OrderDetail entity is created by EF. I need to take the records from that table and bind it to gridview. Instead of showing Product Id I need to show Product name.
Saineshwar BageriPosted Apr 17, 2015, 9:47 AM
Amit JoshiPosted Apr 17, 2015, 9:42 AM
public List
OrderDetail class is created by EF where I have Order Id and Product Id.
I don't have Product Name in this class.
Amit JoshiPosted Apr 17, 2015, 9:32 AM
Saineshwar BageriPosted Apr 17, 2015, 12:39 AM
OrderDBEntities objord = new OrderDBEntities();
var states = (from slist in objord.OrderDetail
join Prd in objord.Product on slist.ProductID equals Prd.ProductID
select new { Prd.productname }).ToList();