Page 1 of 1

LINQ to SQL questions

Posted: Mon 28 Sep 2009 15:40
by joet919
I'm trying to use LINQ to ORacle to get the distinct column values from a table


var query = context.ExecuteQuery("select product_name from dsl_prequal_data where provider_name = 'C1'").Distinct();

foreach (DslPrequalDataN comp in query)
Console.WriteLine(" {0} ", comp.ProductName);


When I try and run this I get an invalidoperationexception because all the columns from the table definition dont exist in the output. How can I get around this? The table is large and has many columns and I want the disctinct value of just this one column name.

Posted: Tue 29 Sep 2009 12:02
by AndreyR
Why don't you use the following code:

Code: Select all

var query = context.ExecuteQuery("select distinct product_name from dsl_prequal_data where provider_name = 'C1'"); 

foreach (string comp in query) 
Console.WriteLine(" {0} ", comp);