Reacting to EF API changes
This commit is contained in:
parent
6120168c86
commit
9b72e3a0bd
|
|
@ -86,9 +86,9 @@ namespace MusicStore.Models
|
|||
{
|
||||
foreach (var item in entities)
|
||||
{
|
||||
db.Entry(item).State = existingData.Any(g => propertyToMatch(g).Equals(propertyToMatch(item)))
|
||||
db.Entry(item).SetState(existingData.Any(g => propertyToMatch(g).Equals(propertyToMatch(item)))
|
||||
? EntityState.Modified
|
||||
: EntityState.Added;
|
||||
: EntityState.Added);
|
||||
}
|
||||
|
||||
await db.SaveChangesAsync();
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ namespace MusicStore.Models
|
|||
cartItem.Count++;
|
||||
|
||||
// TODO [EF] Remove this line once change detection is available
|
||||
_db.Entry(cartItem).State = EntityState.Modified;
|
||||
_db.Entry(cartItem).SetState(EntityState.Modified);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ namespace MusicStore.Models
|
|||
cartItem.Count--;
|
||||
|
||||
// TODO [EF] Remove this line once change detection is available
|
||||
_db.Entry(cartItem).State = EntityState.Modified;
|
||||
_db.Entry(cartItem).SetState(EntityState.Modified);
|
||||
|
||||
itemCount = cartItem.Count;
|
||||
}
|
||||
|
|
@ -95,7 +95,7 @@ namespace MusicStore.Models
|
|||
foreach (var cartItem in cartItems)
|
||||
{
|
||||
// TODO [EF] Change to DbSet.Remove once querying attaches instances
|
||||
_db.Entry(cartItem).State = EntityState.Deleted;
|
||||
_db.Entry(cartItem).SetState(EntityState.Deleted);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ namespace MusicStore.Areas.Admin.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
db.Entry(album).State = EntityState.Modified;
|
||||
db.Entry(album).SetState(EntityState.Modified);
|
||||
await db.SaveChangesAsync(Context.RequestAborted);
|
||||
//Invalidate the cache entry as it is modified
|
||||
cache.Remove(string.Format("album_{0}", album.AlbumId));
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@ namespace MusicStore.Models
|
|||
{
|
||||
foreach (var item in entities)
|
||||
{
|
||||
db.Entry(item).State = existingData.Any(g => propertyToMatch(g).Equals(propertyToMatch(item)))
|
||||
db.Entry(item).SetState(existingData.Any(g => propertyToMatch(g).Equals(propertyToMatch(item)))
|
||||
? EntityState.Modified
|
||||
: EntityState.Added;
|
||||
: EntityState.Added);
|
||||
}
|
||||
|
||||
await db.SaveChangesAsync();
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ namespace MvcMusicStore.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_storeContext.Entry(album).State = EntityState.Modified;
|
||||
_storeContext.Entry(album).SetState(EntityState.Modified);
|
||||
|
||||
await _storeContext.SaveChangesAsync();
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ namespace MvcMusicStore.Controllers
|
|||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
_storeContext.Entry(album).State = EntityState.Modified;
|
||||
_storeContext.Entry(album).SetState(EntityState.Modified);
|
||||
|
||||
await _storeContext.SaveChangesAsync();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue