Updating for EntityFramework API change to DbContext Entry Methods
This commit is contained in:
parent
2286b14290
commit
b580856e66
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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));
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue