I have a class which has this property among others:
public class ADUser
{
public IList<string> Relations { get; set; }
}
In my database table, Relations
is a comma-separated string column.
I am using Dapper to get data.
This is my code:
public ADUser[] GetWithGroupsAndRelations()
{
using (var connection = ConnectionFactory.CreateConnection())
{
int numberOfUsersProcessed = 0;
_log.LogInfo("Getting users from database...");
var users = connection.GetList<ADUser>().ToArray();
//var users = connection.GetList<ADUser>().Take(1000).OrderBy(x => x.Id).ToArray();
_log.LogInfo($"Done getting {users.Count()} users from database...");
return users;
}
}
How can I map the comma-separated Relations
column to a list of strings while reading the data?
Thanks. :)