FoxTrotCharlieZulu
FoxTrotCharlieZulu
CC#
Created by FoxTrotCharlieZulu on 12/1/2022 in #help
❔ Assign JSON API Results To DTO
hey if I am returning json data from an API how do I assign the json data to my DTO? Meaning if I have a DTO that looks like this
public class TestDTO
{
public Data data { get; set; }
}
public class Data
{
public string fname { get; set; }
public string lname { get; set; }
public string phonenNumber { get; set; }
}
public class TestDTO
{
public Data data { get; set; }
}
public class Data
{
public string fname { get; set; }
public string lname { get; set; }
public string phonenNumber { get; set; }
}
but I only want to assign a value to fname and lname how would I set that up?
TestDTO td = null;

//code here

td = new TestDTO
{
//how do I get to fname here?
};
TestDTO td = null;

//code here

td = new TestDTO
{
//how do I get to fname here?
};
6 replies
CC#
Created by FoxTrotCharlieZulu on 11/16/2022 in #help
❔ Setting Up NLog with DI
I have my appsettings.json all set-up, and I have installed the nlog nuget. How do I set-up NLog to use with DI something similar to the below?
public static void Main(string[] args)
{
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddHostedService<Worker>();
services.AddSingleton<ProcessingService>();
services.AddSingleton<Utilities>();
// services.AddSingleton<NLog>();
})
.Build();

host.Run();
}
public static void Main(string[] args)
{
IHost host = Host.CreateDefaultBuilder(args)
.ConfigureServices(services =>
{
services.AddHostedService<Worker>();
services.AddSingleton<ProcessingService>();
services.AddSingleton<Utilities>();
// services.AddSingleton<NLog>();
})
.Build();

host.Run();
}
4 replies