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 158219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:38:34+00:00 2026-05-11T10:38:34+00:00

Okay, simple question.. :) In my webportal I got users, who obviously need to

  • 0

Okay, simple question.. 🙂

In my webportal I got users, who obviously need to log on.

I got a table with users in a MSSQL-DB:

  • PK – GUID – UserId
  • CK – nvarchar – Email
  • CK – nvarchar – PhoneNumber

Now, I want users to be able to log on to my site using either their phonenumber or email, so I need to somehow fetch a user using either the phonenumber or email (both of which are guarenteed to be unique).

In NHibernate, the ISession only allows me to load an entity using the primary key (which is basically a surrogate key in my case). Is there anyway to load entities using candidate keys?

I’m very rusty in database-design, so this might be poor design, but I really think it’s somewhat common to have a scheme like this – but if it is poor design, please let me know 🙂

Thanks in advance

  • 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. 2026-05-11T10:38:35+00:00Added an answer on May 11, 2026 at 10:38 am

    Haven’t used NHibernate, but in Java, using Session::executeQuery with some simple HQL would fetch the correct object. First, I assume that Hibernate’s ‘Session’ is equivilent to NHibernates ‘ISession’. Second, I assume HQL is the same for both. If both of those are true, you’d probably use something like:

    user = isession.executeQuery('from Users where Email = ?'); 

    or

    user = isession.executeQuery('from Users where PhoneNumber = ?'); 

    Again, because I haven’t worked with NHibernate, there may be some differences in syntax. Hope it helps!

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

Sidebar

Related Questions

Okay, pretty simple question. I think I need to drop in some escape characters,
Okay this may be a simple question but I have yet to come with
Okay, this is following on from my previous question reguarding performing a simple ajax
Okay, ridiculously simple question, but it is doing my head in so any help
Okay, this is (probably) a very simple question, but I am afraid I know
Okay, I have what I think is a simple question.. or just a case
Okay so my question is this. Say I have a simple C++ code: #include
Simple question: in MVC, is it okay for one model to interact with another?
Simple question about best-practice. I'm using Kohana... is it okay to use helpers in
Just a simple question, say I have a table and one of their attributes

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.