I have the following statement in LINQ:
var eventsWithTag = (from occurence in occurrences1
join eventTag in serviceContext.CreateQuery("adx_eventtag_event")
on occurence.Event.GetAttributeValue<Guid>("adx_eventid") equals eventTag.GetAttributeValue<Guid>("adx_eventid")
join tag in serviceContext.CreateQuery("adx_eventtag")
on eventTag.GetAttributeValue<Guid>("adx_eventtagid") equals tag.GetAttributeValue<Guid>("adx_eventtagid")
where tag.GetAttributeValue<string>("adx_name") == "scotland"
select occurence).OrderBy(x => x.Start);
This works fine with the fixed string search of "Scotland" in this instance. However I need to replace that to reflect the current page topic. So essentially I need to replace
== "scotland"
with
== getBranch()
where getBranch returns the relevant branch name as a string.
This would lead me to try
eventsWithTag = (from occurence in occurrences1
join eventTag in serviceContext.CreateQuery("adx_eventtag_event") on occurence.Event.GetAttributeValue<Guid>("adx_eventid") equals eventTag.GetAttributeValue<Guid>("adx_eventid")
join tag in serviceContext.CreateQuery("adx_eventtag") on eventTag.GetAttributeValue<Guid>("adx_eventtagid") equals tag.GetAttributeValue<Guid>("adx_eventtagid")
where tag.GetAttributeValue<string>("adx_name") == getBranch()
select occurence).OrderBy(x => x.Start);
But this doesnt work, and from what little I know of LINQ it is because you cant use variables in this way.
So my question is: How can I use the LINQ query above with a dynamic value for the branch.
Please note: I have seen other posts about this but I evidently don't have the LINQ knowledge to transfer them to my specific needs. Just yet!