new dbcontext UpdateOrCreate
This commit is contained in:
parent
9e61c29b94
commit
d9e10ae471
@ -38,5 +38,18 @@ namespace EnotaryoPH.Data
|
|||||||
public DbSet<TransactionSignatoryDeclineReason> TransactionSignatoryDeclineReasons { get; set; }
|
public DbSet<TransactionSignatoryDeclineReason> TransactionSignatoryDeclineReasons { get; set; }
|
||||||
public DbSet<User> Users { get; set; }
|
public DbSet<User> Users { get; set; }
|
||||||
public DbSet<VideoRecording> VideoRecordings { get; set; }
|
public DbSet<VideoRecording> VideoRecordings { get; set; }
|
||||||
|
|
||||||
|
public TEntity UpdateOrCreate<TEntity>(TEntity entity) where TEntity : class
|
||||||
|
{
|
||||||
|
if (Entry(entity).State == EntityState.Detached)
|
||||||
|
{
|
||||||
|
Set<TEntity>().Add(entity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Set<TEntity>().Update(entity);
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user