Select Columns From Multiple Tables Using LINQ
From Northwind database, to show all available products it needs to select values from multiple tables because in Products table there are two columns – CategoryID and SupplierID which are referenced from Category and Suppliers tables. There are more then one options to do this but I use below way to select from multiple tables and bind to grid. First of all create a class and create properties, ProductID, ProductName, CompanyName, CategoryName, UnitPrice. These are the properties which I want to show in grid. public class AvailableProducts { public int ProductID { get ; set ; } public string ProductName { get ; set ; } public string CompanyName { get ; set ; } public string CategoryName { get ; set ; } public decimal UnitPrice { get ; set ; } } Now, write below function in data access layer: public List < AvailableProducts > GetAllAvailableProducts() { var linqAllProducts = from p in NorthwindEntity.Products from c in NorthwindEntity.Categories from s in NorthwindEntity.Supp...