nanonerd
nanonerd

Reputation: 1984

LINQ: use anonymous type

I'm sure that this is basic for someone that knows the answer. But I'm stuck. I've tried to look up the answer to no avail. How do I reference the fbRegistered value later in the code?

using (kvEntities ent = new kvEntities())
    {           
        var user = from u in ent.kvUsers
                   where u.fbID == id
                   select new { u.fbID, u.fbRegistered};

        if (user.fbRegistered)   // < ???
        {
            // so how do I reference fbRegistered just above? 
            // this gives me an error.
        }
  }

Thanks!

Upvotes: 1

Views: 66

Answers (1)

k.m
k.m

Reputation: 31484

The user contains collection. Use First or Single methods:

if (user.First().fbRegistered) ...

Upvotes: 2

Related Questions