I'm using SQL and I have a table shown below in my DB.
Id Remark1 Remark2 Remark3 Remark4
------------------------------------------------
1 AAA BBB CCC DDD
2 EEE FFF GGG HHH
How can I get all the values from Remark*
columns as IEnumerable<string>
using the following DTO?
class MyDTO
{
public int ID { get; }
public IEnumerable<string> Remarks { get; }
}
NOTE: I'm using SqlKata (Dapper), which you can also use when answering.
If you're using Dapper, maybe just use the non-generic Query API. This returns each row as
dynamic
, but this can also be cast toIDictionary<string,object>
, which allows you to access each named column (for example, viaforeach
).