User-357141231 posted
Hi Guys.
Trying to how out how EF handles changes before being saved to DB.
For instance, I am checking the hashes of files, if a hash matches, I point the object to the hash of another object. Or if there is no hash, I create a hash.
I call add or update depending.
I will loop through this and then save at the end.
I've noticed that unless saved, the hashes that have been updated or pointed to another has are not recognized unless it's saved to DB. I thought EF might keep a map in memory before saved, but this doesn't seem to be the case.
Any recommendation here?
Here's a snippet
// check database for another copy
var _checkHash = _appDbContext.ImageHash.Where(h => h.Hash == _hash.ToString()).FirstOrDefault();
if (_checkHash != null)
{
Console.WriteLine("A match was found!");
// update image with hash from image found
_dbImageMagikImage.Hash = _checkHash;
_appDbContext.Update(_dbImageMagikImage);
This will be looped through depending how many there are.