-
Notifications
You must be signed in to change notification settings - Fork 351
/
SqlServerDatabaseResource.cs
29 lines (25 loc) · 1.2 KB
/
SqlServerDatabaseResource.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
namespace Aspire.Hosting.ApplicationModel;
/// <summary>
/// A resource that represents a SQL Server database that is a child of a SQL Server container resource.
/// </summary>
/// <param name="name">The name of the resource.</param>
/// <param name="databaseName">The database name.</param>
/// <param name="parent">The parent SQL Server server resource.</param>
public class SqlServerDatabaseResource(string name, string databaseName, SqlServerServerResource parent) : Resource(name), IResourceWithParent<SqlServerServerResource>, IResourceWithConnectionString
{
/// <summary>
/// Gets the parent SQL Server container resource.
/// </summary>
public SqlServerServerResource Parent { get; } = parent;
/// <summary>
/// Gets the connection string expression for the SQL Server database.
/// </summary>
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create($"{Parent};Database={DatabaseName}");
/// <summary>
/// Gets the database name.
/// </summary>
public string DatabaseName { get; } = databaseName;
}