I'm trying to work out how best to filter Posts by their Fields/Regions in Piranha without loading them all and then performing the filtering.
At the moment I have the following:
var posts = _db.Posts
.Where(p => p.Published >= DateTime.Now)
.Where(x => x.title == "somestring")
.Select(p => p.Id)
.ToList();
If I wanted to query a field in regions named FooArticleDetails how would I modify the above to achieve this?
I can retrieve the results by loading all the Posts and their related Regions but this is not preferred for obvious reasons.
loadedItems.Posts
.Where(post =>
suppliedDiff.Contains(
"hard",
post.Regions.FooArticleDetails.difficulty.Value)).ToLower()
))
.ToList();
I've figured it out. Post Regions are stored as PostFields. These can be accessed via the Fields property.