Compare commits
No commits in common. "9643be09c01a10a606b660bf878e59f768f15ef3" and "6d1b642dac18aeb1f2de3237e9b942e2b4a3d518" have entirely different histories.
9643be09c0
...
6d1b642dac
|
@ -1,4 +1,5 @@
|
|||
using Bunny.Dao.Entity.Base;
|
||||
using Bunny.Common.Interceptor;
|
||||
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.Context.Database;
|
||||
namespace Bunny.Common.Interceptor;
|
||||
|
||||
public class TransactionInterceptor : SaveChangesInterceptor
|
||||
{
|
|
@ -61,17 +61,22 @@ 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 <= 100; i++)
|
||||
list.Add(new Blog { Url = $"Blog{i}" });
|
||||
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()
|
||||
});
|
||||
|
||||
DbContext.Blogs.AddRange(list);
|
||||
DbContext.SaveChanges();
|
||||
transaction.Commit();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除BLog
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue