Reputation: 71
I'm using below code to get a content control by its tag-name.
// Gets content control of the sub table by tag.
var sdtSubTable =
mainPart.Document.Descendants<SdtElement>()
.Where(s => s.SdtProperties.GetFirstChild<Tag().Val.Value.Contains("tagname"));
But this only returns one control, however I have multiple content controls with the same name and I need to retrieve all using LINQ.
LINQ will save time hence using it otherwise would have to loop all content control and then find the matching one.
Any help on this?
Upvotes: 2
Views: 874
Reputation: 71
Found the solution.
List<SdtBlock> sdtSubTable = mainPart.Document.Body.Descendants<SdtBlock>().Where
(r => r.SdtProperties.GetFirstChild<Tag>().Val.Value.Contains("tagname")).ToList();
Upvotes: 1