K
K
Klerkli2015-02-03 12:50:46
SQL
Klerkli, 2015-02-03 12:50:46

What is the reason for the error A field or property with the name 'Key' was not found on the selected data source?

I need to group by order.OrderID

var query = from order in mydb.Orders
    join customer in mydb.Customers on order.CustomerID equals customer.CustomerID
    join employee in mydb.Employees on order.EmployeeID equals employee.EmployeeID
    join shipper in mydb.Shippers on order.ShipVia equals shipper.ShipperID
   join orderdetail in mydb.Order_Details on order.OrderID equals orderdetail.OrderID
     join product in mydb.Products on orderdetail.ProductID equals product.ProductID
      select new
  {
OrderID = order.OrderID,                                 
CustomerName = customer.CompanyName,                                         
EmployeeName = employee.FirstName,
ShipperName = shipper.CompanyName,                                   
Products = product.ProductName,                                         
TotalPrice = orderdetail.UnitPrice * orderdetail.Quantity           
 }  into d
      group d by d.OrderID;

Then I want to output data here
<asp:LinqDataSource 
    ContextTypeName="NorthDataContext" 
    TableName="Contacts" 
    Where="EmailPromotion=1"
    ID="Linq" 
    runat="server">
            
</asp:LinqDataSource>
         <asp:GridView ID="Grid" runat="server">
               </asp:GridView>

I take it out like this
Grid.DataSource = query;
                Grid.DataBind();

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question