I use EntityFramework on my ASP.NET MVC project.
Let’s say I have the entity below:
public class Project
{
public int ProjectID { get; set; }
public string Description { get; set; }
public string Tags { get; set; }
}
Lets say I have the following data in my DB:
ProjectID: 1
Description: "My first element"
Tags: "one, three, five, seven"
ProjectID: 2
Description: "My second element"
Tags: "one, two, three, six"
ProjectID: 3
Description: "My third element"
Tags: "two, three, four"
I would like to collect all tags from all my records. So: “one, two, three, four, five, six, seven”
How can I do? This may seems a stupid question but I don’t know how to proceed.
Thanks.
You need to use
string.Split()to dig out each tag in your list.then
allTagswill contain all your tags. If you want to put them in one big string again, usestring.Join.