I need to populate a List<string> but when my query returns a null value, no empty string is created in this List.
var maskObj = (from m in context.sistema_DocType_Index
join n in context.sistema_Indexes on m.indexId equals n.id
where m.id == docTypeId
select new maskModel
{
mask = n.mask
}).ToList();
return Content(""+maskObj.Count());
If this query returns 3 rows, and all of them are NULL, I need 3 empty strings in the list.
Is there any way I can achieve this?
I understand that for Sql Server, NULL is an absence of value. Even NULL == NULL returns false, so how could I proceed?
I think you want something like the following:
This uses the null-coalescing operator to use
string.Emptyifn.maskis null.The SQL generated by entity framework should be similar to this:
My answer assumes that you are talking about
maskbeingnullwhen you say “If this query returns 3 rows, and all of them are NULL”.