1

I have a settings table without a primary key that I want to be able to select one column/one row from without any mappings.

How can I do this?

1 Answer 1

1

We can still use raw SQL (underlying DB Engine related):

var session = ... ; // standard session, with access to other mapped stuff
var sql = "SELECT settingCol FROM dbo.myTable WHERE ... ";
var result = session
    .CreateSQLQuery(sql)
    .UniqueResult<string>(); // or <int>

and work with that result without being mapped to any entity. Check the

17.1. Using an ISQLQuery

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, I had a solution but it was less elegant, thank you :)
Great if that helped anyhow ;) Enjoy mighty NHibernate, sir

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.