mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
Use DbContext.Remove/Add instead of DbSet methods
This commit is contained in:
@@ -10,7 +10,7 @@ public static class DbContextExtension
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dbContext"></param>
|
/// <param name="dbContext"></param>
|
||||||
/// <param name="entity">Entity for marking as created.</param>
|
/// <param name="entity">Entity for marking as created.</param>
|
||||||
[Obsolete("DbContextExtension.MarkAsCreated is obsolete, use DbSet<T>.Add instead")]
|
[Obsolete("DbContextExtension.MarkAsCreated is obsolete, use DbContext.Add instead")]
|
||||||
public static void MarkAsCreated(this DbContext dbContext, object entity) =>
|
public static void MarkAsCreated(this DbContext dbContext, object entity) =>
|
||||||
dbContext.Entry(entity).State = EntityState.Added;
|
dbContext.Entry(entity).State = EntityState.Added;
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ public static class DbContextExtension
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dbContext"></param>
|
/// <param name="dbContext"></param>
|
||||||
/// <param name="entity">Entity for marking as deleted.</param>
|
/// <param name="entity">Entity for marking as deleted.</param>
|
||||||
[Obsolete("DbContextExtension.MarkAsDeleted is obsolete, use DbSet<T>.Remove instead")]
|
[Obsolete("DbContextExtension.MarkAsDeleted is obsolete, use DbContext.Remove instead")]
|
||||||
public static void MarkAsDeleted(this DbContext dbContext, object entity) =>
|
public static void MarkAsDeleted(this DbContext dbContext, object entity) =>
|
||||||
dbContext.Entry(entity).State = EntityState.Deleted;
|
dbContext.Entry(entity).State = EntityState.Deleted;
|
||||||
|
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
|||||||
.Where(subscriber => subscriber.Feed == feed && subscriber.SubscriberId == chat.Id)
|
.Where(subscriber => subscriber.Feed == feed && subscriber.SubscriberId == chat.Id)
|
||||||
.Select(subscriber => subscriber.SubscriptionId).FirstAsync();
|
.Select(subscriber => subscriber.SubscriptionId).FirstAsync();
|
||||||
|
|
||||||
_dbContext.Subscriptions.Remove(_dbContext.Find<Subscriber>(subId));
|
_dbContext.Remove(_dbContext.Find<Subscriber>(subId));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -298,7 +298,7 @@ namespace Kruzya.TelegramBot.RichSiteSummary.Handler
|
|||||||
subscription.Feed = feed;
|
subscription.Feed = feed;
|
||||||
subscription.SubscriberId = chat.Id;
|
subscription.SubscriberId = chat.Id;
|
||||||
|
|
||||||
_dbContext.Subscriptions.Add(subscription);
|
_dbContext.Add(subscription);
|
||||||
}
|
}
|
||||||
|
|
||||||
await _dbContext.SaveChangesAsync();
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|||||||
Reference in New Issue
Block a user