When I try and load an entity by ID using:
Session.Load<User>(21);
I get a 'no row with the given identifier exists'.
In my code I was checking for null like:
if(user == null)
How am I suppose to know if the row didn't exist, or how can I make it return null instead?
Because it doesn't actually make a round-trip to the database. You are actually getting back a proxy for lazy loading so NHibernate can't know if it really exists or not. If you need to know if really exists, you should use:
var entity = Session.Get(21)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With