Compare commits
2 Commits
6d1b642dac
...
9643be09c0
Author | SHA1 | Date |
---|---|---|
|
9643be09c0 | |
|
57eb804feb |
|
@ -1,5 +1,4 @@
|
|||
using Bunny.Common.Interceptor;
|
||||
using Bunny.Dao.Entity.Base;
|
||||
using Bunny.Dao.Entity.Base;
|
||||
using Bunny.Dao.Entity.System;
|
||||
using log4net;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using Bunny.Dao.Common.Constant;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
|
||||
namespace Bunny.Common.Interceptor;
|
||||
namespace Bunny.Common.Context.Database;
|
||||
|
||||
public class TransactionInterceptor : SaveChangesInterceptor
|
||||
{
|
|
@ -61,22 +61,17 @@ public class BlogService : IBlogService
|
|||
/// <param name="url"></param>
|
||||
public void AddBatchBlogs(string url)
|
||||
{
|
||||
using var transaction = DbContext.Database.BeginTransaction();
|
||||
var list = new List<Blog>();
|
||||
for (var i = 0; i <= 100000; i++)
|
||||
list.Add(new Blog
|
||||
{
|
||||
Url = url,
|
||||
CreateTime = DateTime.Now,
|
||||
UpdateTime = DateTime.Now,
|
||||
UpdateUserId = Random.Shared.Next(),
|
||||
CreateUserId = Random.Shared.NextInt64()
|
||||
});
|
||||
|
||||
for (var i = 0; i <= 100; i++)
|
||||
list.Add(new Blog { Url = $"Blog{i}" });
|
||||
|
||||
DbContext.Blogs.AddRange(list);
|
||||
DbContext.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除BLog
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue