如何使用 lambda 编写 "select * from PUB_PAGE_MENUSTRUCTUR where PARENTID is null"

how to write "select * from PUB_PAGE_MENUSTRUCTUR where PARENTID is null" using lambda

这是我从 pub_page_menustructur

获取数据的 lambda

DataHelper.DataObj.QueryTable(SystemType.H0, p=>p.PARENTID == null) 这是我写的 lambda 表达式。与图中"select * from pub_page_menustructur where parentid = null"效果相同。有没有其他方式显示为 "parentid is null"

如果您使用的是 Entity Framework

,则此方法适合您
var result = dbcontext.PUB_PAGE_MANUSTRUCTURE.Where(w => w.PARENTID == null).ToList();

答案是 var result = dbcontext.PUB_PAGE_MANUSTRUCTURE.Where(w => w.PARENTID.Trim() == null).ToList();