Reputation: 9541
This is my unit test (it's quite meaningless but proves a point
Config entity = new Config("key", "value");
Session.SaveOrUpdate(entity);
Config config = Session.Query<Config>().SingleOrDefault(c => c.Key == "key");
Assert.IsNotNull(config);
it fails...but I don't think it should (note, if I flush it, it doesn't fail, but that's not the behaviour I want)
If I replace the query line with this
Config config = Session.Get<Config>("key");
...it passes
At no point does it flush (I even set the FlushMode to never just to be sure). Why would one be successful, and the other not? This doesn't seem right - and I would very much like the linq one to be successful
Upvotes: 3
Views: 895
Reputation: 502
This article:
Seems to suggest that a Query will go to the database, bypassing the session's cache, whereas Get will try the session first.
Upvotes: 5