I know how to grab all the instances of a specifc content type, however I want to only get instances of that content type that have a specific property value;
var value = 11;
var repo = ServiceLocator.Current.GetInstance<IContentTypeRepository>();
var usage = ServiceLocator.Current.GetInstance<IContentModelUsage>();
var contentType = repo.Load<YourContentType>();
var usages = contentModelUsage.ListContentOfContentType(contentType);
// is there a native EPiServer way of doing the following without having to GetInstance<>() each instance?
var matches = usages.Select(pl => ServiceLocator.Current.GetInstance<YourContentType>(pl)).Where(c => c.SomeProperty == value);
Is there an EPiServer SDK way of doing this so that I do not have to use GetInstance for each of the content items?
This is how I did it, too, I don't know any other way. I believe that EPiServer Find is meant to be used in these cases.
If you want to load content with a specific property value I would look at using search instead, using search to find out the content id and load it that way.
If you don't have EPiServer Find installed, try with a simple FindPagesWithCriteria. Note that FindPagesWithCriteria runs queries directly to the database so I would recommend that you're using Cache on your results.
Thanks to you all for your replies. Very helpful.
Sadly, EPiFind is not a solution for us because client did not want to use it.
However, we will be using a bespoke SOLR solution for site search. Perhaps it makes sense to add all of the content item properties to the search index rather than just the textual/end-user searchable properties.Then I can make use of that solution for this purpose.
If you only want to depend on internal EPiServer functionality, you still have FindPagesWithCriteria where you can read directly against content EPiServer instead of relying on indexed data in a third party solution