C# – Select Single Value with ADO.Net Data Services and LINQ

clinqwcf-data-services

Trying my hand at ADO.Net data services. All the examples shows how to retrieve lists but how would you go about retrieving a single value? e.g. Product X's Price.

Here is the LINQ query i use:

var qry = (from p in
svcContext.Products
where p.ProductName == "Chair"
&& p.Colour == 1
select c) as DataServiceQuery;

Product returnedProd;

qry.BeginExecute(
(pr) => returnedProd = qry.EndExecute(pr).First(), null);

Here i try to retrieve the product and load it into a local variable, but the local var stays null.

Pretty sure, i'm doing it completely wrong :)…any help would be greatly appreciated.

Best Answer

It's not suppose to be

var qry = (from p in svcContext.Products where p.ProductName == "Chair" && p.Colour == 1 select p) where did you declare the c ?