this query will just one row as a result
myDataContext db = new myDataContext(); var query = from u in db.users where u.userId == myUserId select u;
I usually get the result out from the ‘query’ object by using ‘foreach’
foreach(var i in query){ username = i.username; } Response.Write(username);
but that does not make sense if case if the object have just one row
so what is the best way to fetch data from object when I am sure it just have one row?
just use query.Single().