Are you an LLM? You can read better optimized documentation at /documents/querying/linq/nulls.md for this page in Markdown format
Searching for NULL Values
Regardless of your feelings about NULL, they do exist in databases and Marten allows you to search for documents that have (or don't have) null values:
cs
public async Task query_by_nullable_type_nulls(IDocumentSession session)
{
// You can use Nullable<T>.HasValue in Linq queries
await session.Query<Target>().Where(x => !x.NullableNumber.HasValue).ToListAsync();
await session.Query<Target>().Where(x => x.NullableNumber.HasValue).ToListAsync();
// You can always search by field is NULL
session.Query<Target>().Where(x => x.Inner == null);
}
