mirror of https://github.com/abpframework/abp.git
29 changed files with 143 additions and 82 deletions
@ -0,0 +1,40 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace Volo.Abp.MultiTenancy |
|||
{ |
|||
public class Tenant : AggregateRoot |
|||
{ |
|||
public string Name { get; protected set; } |
|||
|
|||
public List<TenantConnectionString> ConnectionStrings { get; protected set; } |
|||
|
|||
protected Tenant() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public Tenant(Guid id, [NotNull] string name) |
|||
{ |
|||
Id = id; |
|||
Name = name; |
|||
|
|||
ConnectionStrings = new List<TenantConnectionString>(); |
|||
} |
|||
|
|||
[CanBeNull] |
|||
public virtual string FindDefaultConnectionString() |
|||
{ |
|||
return FindConnectionString(Data.ConnectionStrings.DefaultConnectionStringName); |
|||
} |
|||
|
|||
[CanBeNull] |
|||
public virtual string FindConnectionString(string name) |
|||
{ |
|||
return ConnectionStrings.FirstOrDefault(c => c.Name == name)?.Value; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.Domain.Entities; |
|||
|
|||
namespace Volo.Abp.MultiTenancy |
|||
{ |
|||
public class TenantConnectionString : Entity |
|||
{ |
|||
public virtual Guid TenantId { get; protected set; } |
|||
|
|||
public virtual string Name { get; protected set; } |
|||
|
|||
public virtual string Value { get; protected set; } |
|||
|
|||
protected TenantConnectionString() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public TenantConnectionString(Guid tenantId, [NotNull] string name, [NotNull] string value) |
|||
{ |
|||
Check.NotNull(name, nameof(name)); |
|||
Check.NotNull(value, nameof(value)); |
|||
|
|||
TenantId = tenantId; |
|||
Name = name; |
|||
Value = value; |
|||
} |
|||
} |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
using System; |
|||
using JetBrains.Annotations; |
|||
using Volo.Abp.Data; |
|||
|
|||
namespace Volo.Abp.MultiTenancy |
|||
{ |
|||
public class TenantInformation |
|||
{ |
|||
public Guid Id { get; protected set; } |
|||
|
|||
public string Name { get; protected set; } |
|||
|
|||
public ConnectionStrings ConnectionStrings { get; protected set; } |
|||
|
|||
protected TenantInformation() |
|||
{ |
|||
|
|||
} |
|||
|
|||
public TenantInformation(Guid id, [NotNull] string name) |
|||
{ |
|||
Id = id; |
|||
Name = name; |
|||
|
|||
ConnectionStrings = new ConnectionStrings(); |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue