Skip to content

Commit

Permalink
🎨 调整DbSeed批量写入
Browse files Browse the repository at this point in the history
  • Loading branch information
LemonNoCry committed Aug 30, 2023
1 parent 6d0a3df commit 39fc0ab
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions Blog.Core.Common/Seed/DBSeed.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,7 @@ public static async Task SeedAsync(MyContext myContext, string WebRootPath)
{
var data = JsonConvert.DeserializeObject<List<Permission>>(FileHelper.ReadFile(string.Format(SeedDataFolder, "Permission"), Encoding.UTF8), setting);

foreach (var item in data)
{
Console.WriteLine($"{item.Name}:{item.Id}");
myContext.GetEntityDB<Permission>().Insert(item);
}
myContext.GetEntityDB<Permission>().InsertRange(data);
Console.WriteLine("Table:Permission created success!");
}
else
Expand Down Expand Up @@ -218,11 +214,7 @@ public static async Task SeedAsync(MyContext myContext, string WebRootPath)
{
var data = JsonConvert.DeserializeObject<List<RoleModulePermission>>(FileHelper.ReadFile(string.Format(SeedDataFolder, "RoleModulePermission"), Encoding.UTF8), setting);

foreach (var item in data)
{
Console.WriteLine($"{item.Id}");
myContext.GetEntityDB<RoleModulePermission>().Insert(item);
}
myContext.GetEntityDB<RoleModulePermission>().InsertRange(data);
Console.WriteLine("Table:RoleModulePermission created success!");
}
else
Expand Down

2 comments on commit 39fc0ab

@NingLiu1998
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嘶,改动原因是啥

@LemonNoCry
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

循环插入太慢了

Please sign in to comment.