I have query in link to SQL like this
var password = (from userAccounts in myDb.Physicians
where userAccounts.Phy_UserName == txtUserName.Text
select userAccounts).FirstOrDefault();
I want to select a specific column with that query, I want to retrieve the row value of userAccounts.Password, userAccounts.Phy_FName, userAccounts.Phy_Password and so on.
is password.Phy_FName allowed? assuming that we have a result? how do I select a value?
You’ve got it right. your
Phy_UserNameneeds to be a column in your database. It’s returning aPhysiciansobject and you can get each value as follows.now if you choose to only select your needed properties, you will approach it a little differently.
Edit
As per your comment below, this is a little aside pertaining to preventing a
nullvalue being inserted into astring(nvarchar) field in the database.The easiest way to do this is to add the required attribute to the property and ensure you’re validating it before submitting it.
If you set the allow null to
falsein the database, and then update your DBML file to reflect the changes, then the[required]attribute will be added to the property automatically.