I have a C# Class called Person and within that class, the Person has a Telephone property of type TelephoneDetails.
I am trying to Query a Database using Dapper and within my Query, I need to retrieve the current telephone number (known as Detail) and put it into my Telephone property.
Here's what I've tried:
var person = _connection.Query<Person>($"SELECT person AS Person, Detail AS {new TelephoneDetails{Telephone = ""}} " + // Here's my issue
"FROM dbo.Foo WHERE PersonId = @id",
new {id}).FirstOrDefault();
return person;
Every time I return the local variable person I return a null value in my Telephone Property. How do I take the data from the database instantiate the property?
I feel I have given everything needed but if not please use the comments section for clarification.
Thanks in advance.