多租户应用程序设计
This commit is contained in:
1 parent
dbabaaadba
commit
49f2796cc2
24 files changed
+116
-25
No files matched your search
+7
-4
@@ -1,16 +1,19 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using MultiTenancySample.FieldIsolationService.Entities;
|
||||
using MultiTenancySample.ServiceDefaults;
|
||||
|
||||
namespace MultiTenancySample.FieldIsolationService.EntityFrameworks
|
||||
{
|
||||
public class DataSeeding(IDbContextFactory<FieldIsolationServiceDbContext> dbContext, ICurrentTenant currentTenant)
|
||||
public class DataSeeding(IDbContextFactory<FieldIsolationServiceDbContext> dbContextFactory, ICurrentTenant currentTenant)
|
||||
{
|
||||
public async Task SeedDataAsync()
|
||||
{
|
||||
currentTenant.SetTenant("Tenant1");
|
||||
|
||||
FieldIsolationServiceDbContext dbContext1 = await dbContext.CreateDbContextAsync();
|
||||
FieldIsolationServiceDbContext dbContext1 = await dbContextFactory.CreateDbContextAsync();
|
||||
|
||||
if (await dbContext1.Database.EnsureCreatedAsync())
|
||||
{
|
||||
@@ -25,7 +28,7 @@ namespace MultiTenancySample.FieldIsolationService.EntityFrameworks
|
||||
|
||||
currentTenant.SetTenant("Tenant2");
|
||||
|
||||
FieldIsolationServiceDbContext dbContext2 = await dbContext.CreateDbContextAsync();
|
||||
FieldIsolationServiceDbContext dbContext2 = await dbContextFactory.CreateDbContextAsync();
|
||||
|
||||
if (await dbContext2.Set<Product>().IgnoreQueryFilters().CountAsync() < 6)
|
||||
{
|
||||
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Microsoft.EntityFrameworkCore.Query;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using MultiTenancySample.FieldIsolationService.Entities;
|
||||
using MultiTenancySample.ServiceDefaults;
|
||||
|
||||
+4
-1
@@ -1,4 +1,7 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using MultiTenancySample.FieldIsolationService.Entities;
|
||||
|
||||
Reference in new issue
Block a user