I have a nullable bool which contains true / false / null on a SQL server database. I am trying to query the server to return a dataset which contains false FlagForDelete
records and another to return null FlagForDelete
records. I've tried several things and cannot isolate the two data sets I need for my target condition.
Can someone provide a hint on how I can accomplish this? Thanks very much.
Target condition
Dataset1 to contain only false records.
Dataset2 to contain only null records.
I've tried the below code and can't get it to work. I get all records regardless of true/false/null.
Dataset
MaterialID | StockQty | FlagForDelete
----------------------------------------------
MAT1 | 10 | true
MAT2 | 20 | false
MAT3 | 30 | null
Model
public class Material
{
public int MaterialID { get; set; }
public decimal? StockQty { get; set; }
public bool? FlagForDelete { get; set; }
}
Controller
IQueryable<Material> Dataset1 = _context.Material.AsNoTracking().Where(ffd => ffd.FlagForDelete == false);
IQueryable<Material> Dataset2 = _context.Material.AsNoTracking().Where(ffd => ffd.FlagForDelete == null);