Share via


ResourceBuilderExtensions.WithRelationship<T> Method

Definition

Adds a ResourceRelationshipAnnotation to the resource annotations to add a relationship.

public static Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithRelationship<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, Aspire.Hosting.ApplicationModel.IResource resource, string type) where T : Aspire.Hosting.ApplicationModel.IResource;
static member WithRelationship : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)> * Aspire.Hosting.ApplicationModel.IResource * string -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)> (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)
<Extension()>
Public Function WithRelationship(Of T As IResource) (builder As IResourceBuilder(Of T), resource As IResource, type As String) As IResourceBuilder(Of T)

Type Parameters

T

The type of the resource.

Parameters

builder
IResourceBuilder<T>

The resource builder.

resource
IResource

The resource that the relationship is to.

type
String

The relationship type.

Returns

A resource builder.

Examples

This example shows adding a relationship between two resources.

var builder = DistributedApplication.CreateBuilder(args);
var backend = builder.AddProject<Projects.Backend>("backend");
var manager = builder.AddProject<Projects.Manager>("manager")
                     .WithRelationship(backend.Resource, "Manager");

Remarks

The WithRelationship method is used to add relationships to the resource. Relationships are used to link resources together in UI. The type indicates information about the relationship type.

Applies to