Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7598183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T22:20:43+00:00 2026-05-30T22:20:43+00:00

I have query in link to SQL like this var password = (from userAccounts

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T22:20:45+00:00Added an answer on May 30, 2026 at 10:20 pm

    You’ve got it right. your Phy_UserName needs to be a column in your database. It’s returning a Physicians object and you can get each value as follows.

    // `var physician` is the same as `Physician physician` 
    // where you're declaring a Physician object from your DBML file
    
    // we're using `p` for `physician` in the lambda select function
    var physician = (from p in myDb.Physicians
                     where p.Phy_UserName == txtUserName.Text
                     select p).FirstOrDefault();
    
    // now that you've got a `physician` object, you can use the properties
    // within the object as follows..
    var password = physician.Password;
    var firstName = physician.Phy_FName;
    // etc
    
    // please note that the physician object you have currently has ALL of the 
    // database fields for that particular physician
    

    now if you choose to only select your needed properties, you will approach it a little differently.

    // first you declare a poco to store only the needed properties.
    
    public class PhysicianViewModel {
        public string Password {get; set;}
        public string FirstName {get; set;}
    }
    
    // then you run your select query and drill down to grab
    // only the required data fields from the database
    var physicianViewModel = (from p in myDb.Physicians
                              where userAccounts.Phy_UserName == txtUserName.Text
                              select new PhysicianViewModel { 
                                  Password = p.Password,
                                  FirstName = p.Phy_FName }).FirstOrDefault();
    
    // and using them is the same as the above example
    // the only difference here is that the `physicianViewModel` doesn't 
    // contain ANY properties other than the ones you specified.
    var password = physicianViewModel.Password;
    var firstName = physicianViewModel.FirstName;
    

    Edit

    As per your comment below, this is a little aside pertaining to preventing a null value being inserted into a string (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.

    public class Physician {
        [Required]
        public string Password {get; set;}
        public string Phy_FName {get; set;}
        public string Phy_LName {get; set;}
    }
    

    If you set the allow null to false in the database, and then update your DBML file to reflect the changes, then the [required] attribute will be added to the property automatically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a query that originally looks like this: select c.Id, c.Name, c.CountryCode, c.CustomerNumber,
I have this query in sql server 2000: select pwdencrypt('AAAA') which outputs an encrypted
I have a query that looks like this: public IList<Post> FetchLatestOrders(int pageIndex, int recordCount)
I have a query that I'm executing from a .NET application to a SQL
I have two tables like this: om_manga: id | link | manganame | viewed
I'm really struggling with this query. I have 4 tables (http://oberto.co.nz/db-sql.png): Invoice_Payement, Invoice, Client
I have made an SQL query that picks out web statistics from a database.
I have established a link using Netbeans and Paradox driver and can query the
I have a query on my database as such: SELECT * FROM expenses WHERE
I have a rather large SQL query which the majority of which has come

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.