Updating for EntityFramework API change to DbContext Entry Methods

This commit is contained in:
mikary 2014-12-04 09:53:55 -08:00
parent 2286b14290
commit b580856e66
4 changed files with 6 additions and 6 deletions

View File

@ -86,7 +86,7 @@ namespace MusicStore.Models
{ {
foreach (var item in entities) foreach (var item in entities)
{ {
db.ChangeTracker.Entry(item).State = existingData.Any(g => propertyToMatch(g).Equals(propertyToMatch(item))) db.Entry(item).State = existingData.Any(g => propertyToMatch(g).Equals(propertyToMatch(item)))
? EntityState.Modified ? EntityState.Modified
: EntityState.Added; : EntityState.Added;
} }

View File

@ -55,7 +55,7 @@ namespace MusicStore.Models
cartItem.Count++; cartItem.Count++;
// TODO [EF] Remove this line once change detection is available // TODO [EF] Remove this line once change detection is available
_db.ChangeTracker.Entry(cartItem).State = EntityState.Modified; _db.Entry(cartItem).State = EntityState.Modified;
} }
} }
@ -75,7 +75,7 @@ namespace MusicStore.Models
cartItem.Count--; cartItem.Count--;
// TODO [EF] Remove this line once change detection is available // TODO [EF] Remove this line once change detection is available
_db.ChangeTracker.Entry(cartItem).State = EntityState.Modified; _db.Entry(cartItem).State = EntityState.Modified;
itemCount = cartItem.Count; itemCount = cartItem.Count;
} }
@ -95,7 +95,7 @@ namespace MusicStore.Models
foreach (var cartItem in cartItems) foreach (var cartItem in cartItems)
{ {
// TODO [EF] Change to DbSet.Remove once querying attaches instances // TODO [EF] Change to DbSet.Remove once querying attaches instances
_db.ChangeTracker.Entry(cartItem).State = EntityState.Deleted; _db.Entry(cartItem).State = EntityState.Deleted;
} }
} }

View File

@ -138,7 +138,7 @@ namespace MusicStore.Areas.Admin.Controllers
{ {
if (ModelState.IsValid) if (ModelState.IsValid)
{ {
db.ChangeTracker.Entry(album).State = EntityState.Modified; db.Entry(album).State = EntityState.Modified;
await db.SaveChangesAsync(Context.RequestAborted); await db.SaveChangesAsync(Context.RequestAborted);
//Invalidate the cache entry as it is modified //Invalidate the cache entry as it is modified
cache.Remove(string.Format("album_{0}", album.AlbumId)); cache.Remove(string.Format("album_{0}", album.AlbumId));

View File

@ -70,7 +70,7 @@ namespace MusicStore.Models
{ {
foreach (var item in entities) foreach (var item in entities)
{ {
db.ChangeTracker.Entry(item).State = existingData.Any(g => propertyToMatch(g).Equals(propertyToMatch(item))) db.Entry(item).State = existingData.Any(g => propertyToMatch(g).Equals(propertyToMatch(item)))
? EntityState.Modified ? EntityState.Modified
: EntityState.Added; : EntityState.Added;
} }