tags:

views:

67

answers:

2

I want to return a single row from the users table using domain account id as my primary and unique key

However when i use singleordefault and see its sql translation it performs entire select * from Users

my query is..

var user = base.SingleorDefault(t=>t.domainaccountid)

i want this to return just one row!

A: 

You could try Where along with FirstOrDefault:

var user = base.Where(t => t.domainaccountid == 123).FirstOrDefault();
Darin Dimitrov
SingleorDefault(pred) still does a `WHERE`, so I don't think this is directly related (although `FirstOrDefault` may be desirable for the `TOP 1` behaviour)
Marc Gravell
+4  A: 

What is base ? Is it possible that you've coerced it to IEnumerable<T> at some point, rather than IQueryable<T>? that would cause this. Note that database composition is only possible when using IQueryable<T>, so if any of your methods have returned something other than this, composition will end.

Marc Gravell