Skip to content

Instantly share code, notes, and snippets.

@skttl
Created March 2, 2016 09:41
Show Gist options
  • Save skttl/30c6a480e334f04e64b5 to your computer and use it in GitHub Desktop.
Save skttl/30c6a480e334f04e64b5 to your computer and use it in GitHub Desktop.
Extension method for getting field value from Examine.SearchResult, with string fallback
using Examine;
namespace MyNamespace
{
public static class ExamineExtensions
{
public static string GetFieldValue(this SearchResult searchResult, string key, string fallback = "")
{
if (searchResult.Fields.Keys.Contains(key))
{
return searchResult.Fields[key];
}
else
{
return fallback;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment