Skip to content

Commit 9de766d

Browse files
#8879: Adding GetNullableDateTime to ISearchHit and LuceneSearchHit (#8883)
1 parent f2f67d3 commit 9de766d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Orchard.Web/Modules/Lucene/Models/LuceneSearchHit.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,19 @@ public bool GetBoolean(string name)
3838
public string GetString(string name)
3939
{
4040
var field = _doc.GetField(name);
41-
return field == null ? null : field.StringValue;
41+
return field?.StringValue;
4242
}
4343

4444
public DateTime GetDateTime(string name)
4545
{
4646
var field = _doc.GetField(name);
4747
return field == null ? DateTime.MinValue : DateTools.StringToDate(field.StringValue);
4848
}
49+
50+
public DateTime? GetNullableDateTime(string name)
51+
{
52+
var field = _doc.GetField(name);
53+
return field == null ? default(DateTime?) : DateTools.StringToDate(field.StringValue);
54+
}
4955
}
5056
}

src/Orchard/Indexing/ISearchHit.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ public interface ISearchHit
1111
bool GetBoolean(string name);
1212
string GetString(string name);
1313
DateTime GetDateTime(string name);
14+
DateTime? GetNullableDateTime(string name);
1415
}
1516
}

0 commit comments

Comments
 (0)