I am using northwind database and try to return product table using linq to sql. below pasted my code.
protected void Page_Load(object sender, EventArgs e)
{
DemoDataContext dbContext = new DemoDataContext();
var lyncQuery = from product in dbContext.Products
where product.CategoryID == 2
orderby product.UnitPrice descending
select product;
ProductDataGrid.DataSource = lyncQuery;
Response.Write(lyncQuery.ToString());
ProductDataGrid.DataBind();
}
}
i verified lyncquery returns all the columns by printing that in response.write, when i debug also i am seeing all the columns value in lyncquery but when i am binding that with datagrid i am seeing only productid, productname, discontinued,quantityperunit as below.
even i tried returning specific columns using below in select clause, select new { product.ProductID, product.ProductName, product.CategoryID, product.SupplierID, product.Discontinued, product.UnitPrice, product.QuantityPerUnit };
but still i am seeing only those 4 columns
any lead can help me in resolve this. Thanks in advance