public static SearchDocument ToSearchDocument(this Document doc) { var data = new SearchDocument() { Identifier = Guid.Parse(doc.Get(SearchDocument.IdentifierKey)), Title = doc.Get(SearchDocument.TitleKey), Description = doc.Get(SearchDocument.DescriptionKey), ImageData = doc.Get(SearchDocument.ImageDataKey), Key = doc.Get(SearchDocument.KeyKey), Location = doc.Get(SearchDocument.LocationKey), MemberName = doc.Get(SearchDocument.MemberNameKey), }; var type = doc.Get(SearchDocument.TypeKey); if (!string.IsNullOrWhiteSpace(type)) { data.Type = (Reference)int.Parse(type); } var createdOn = doc.Get(SearchDocument.CreatedOnKey); if (!string.IsNullOrWhiteSpace(createdOn)) { data.CreatedOn = createdOn.DateTimeExact(); } data.SetPermissions(doc.Get(SearchDocument.PermissionsKey)); return(data); }