asp.net mvc 4, Entity Framework 5, SQL Server 2012 Express, Code First
I have a Place model:
public virtual int PlaceID { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
public virtual string Name { get; set; }
and a related Tag model:
public virtual int TagID { get; set; }
public virtual string Name { get; set; }
public virtual string NamePlural { get; set; }
public virtual ICollection<Place> Places { get; set; }
they have a many to many relationship.
I have a List places - and I would like to create a List tags - populated with every (unique) tag associated with every place in 'places'.
For example, one place might have 'restaurant' and 'pub' tag, another 'pub' and 'bar', and another 'shop' and 'cafe'.
I would like the List to contain one of each of the tags with these names: Bar, Cafe, Restaurant, Pub, Shop
How can I do this in Linq?
Thanks.