Note that if you have a foreign key relationship established in your database, Linq-to-Sql should automatically join you:
var pin = (from u in context.users where u.email == email select u.pintouser.pin).Single();
which means you can reduce this:
var pin = context.users.Where(u=>u.email == email) .Select(u=>u.pintouser.pin) .Single();
(UPDATE Note: I initially suggested the following, which is much shorter, but I believe that this will lead to two back trips to the database)
var pin = context.users.Single(u=>u.email == email).Single().pintouser.pin;
Now .pintouser.pin is safe, because Single() always returns a user object (or throws an exception).
James curran
source share