views:

38

answers:

2

I have a query like:

var fooQuery = (from x in edm.stuff where x.col == DesiredVal select x)

'stuff' is a view. When I count the results I get '1'. When I First() or FirstOrDefault() I get null.

var fooCount = fooQuery.Count(); // results in 1
var fooResult = fooQuery.FirstOrDefault(); // results in null

This doesn't make sense to me. Is there a circumstance that this should be happening?

A: 

are you using a private member in the where statement?

John Nicholas
not sure what would create a private member. the 'id' column is a database column.
DrydenMaker
I did see how to make members private. No that is not my problem. Interesting thought though.
DrydenMaker
what i mean is that in the class you ahve public properties which write to and from the private members. When you write you linq you can use either of these, but only the public property ones will work as intended.
John Nicholas
A: 

Try not to put parenthesis.

Sylvain Perron
same results, but what is the difference between having parenthesis and not. I have gotten in the habit of using them.
DrydenMaker