Created
March 2, 2016 09:41
-
-
Save skttl/30c6a480e334f04e64b5 to your computer and use it in GitHub Desktop.
Extension method for getting field value from Examine.SearchResult, with string fallback
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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