Anicho
Anicho

Reputation: 2667

Linq issue retrieving single value from SQL Server

Hey Guys, having an issue with Linq-to-SQL, I am basically doing the following but it is saying it is "UserProfile does not contain definition for Username" in the current context where I wrote "u.Username" but it does exist I have added UserProfile table to MyDbml.dbml and if I connect to another table it works fine.

TiamoDataContext context = new TiamoDataContext();

var user = (from u in context.UserProfiles
           where u.Username == UsernameLabel
          select u).FirstOrDefault();

I am flustered by what small detail I have missed out to get this to work, anyone have any clues it would be much appreciation.

Upvotes: 0

Views: 220

Answers (1)

Justin Niessner
Justin Niessner

Reputation: 245399

If the compiler says it doesn't exist, then it doesn't exist.

Make sure you check case. Username could really be username. Also make sure you properly added the UserProfiles table from the database.

Without more code (or screenshots of the DBML), there's not much more we can suggest.

Upvotes: 2

Related Questions