i have query that maybe haven’t any element on sequence and i want to add one element to sequence if is empty.
var results = _context.Documents.Select(document => document.MimeType).Distinct().ToList().DefaultIfEmpty("There is nothing to be used as MimeType");
but still sequence is empty however is used DefaultIfEmpty method.
Yes, you can use
DefaultIfEmpty()for this purpose. (However, note that theToList()in your query is redundant.)For example: