Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you think of the cache as a dictionary with a string key, it's obvious that the keys "TEST" and "test" are different because C# is case sensitive.</p> <p>But something doesn't seem right here. How do you know that NH is putting three entities in 2nd level cache? Assuming you're using a case-insensitive database, all three queries generated by the Get method will return the same row and the ID property on the entity will be set using the value returned by the query, not by the value supplied to the Get method. The entities will be cached using the entity's ID also. Do all three Gets return instances with the ID in the same case ("TestMode")?</p> <hr> <p>Update based on the edits to your question, if I understand you correctly:</p> <ul> <li>Get("TestMode") caches the object as expected and retrieves it from cache on subsequent requests for "TestMode"</li> <li>Get("testmode") or any other case goes back to the database</li> </ul> <p>That's the behavior I would expect. The value supplied for id is used to attempt to locate the entity in the cache. If a match is found then the entity is retrieved from cache; if not the database is queried. After the entity is retrieved, NHibnernate attempts to add it to the cache using its id as a key, but it already exists so the cached value is updated, replaced or ignored.</p> <p>The key point is that the id supplied to the query is used as a key to locate the entity in the cache, but the entity's id is used as the key when it is added to the cache.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload