假设我有一个 ASP.NET Core Web API 应用程序,并且我的操作方法之一接收IEnumerable<AddressModel> addresses,如下AddressModel所示:
public class AddressModel
{
public string Street { get; set; }
public string ZipCode { get; set; }
public string City { get; set; }
public string Country { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我想用它来构造一个更复杂的消息对象并通过 MassTransit 发送它 -Addresses将是一个嵌套属性,我将设置更多字段:
public interface ICreateContact
{
ContactTypeEnum Type { get; }
List<IAddress> Addresses { get; }
}
public interface IAddress
{
string Street { get; }
string ZipCode { get; }
string …Run Code Online (Sandbox Code Playgroud)