[英]how to use the condition field is null in Entity Framework Core (Oracle)
I need to use the condition "field is null" in linq, I tried using "field == null" but it doesn't bring me the records.我需要在 linq 中使用条件“field is null”,我尝试使用“field == null”但它没有给我带来记录。
var query = from p in _context.Product
where p.PRODUCT_IND_CHANGE == null
select new ProductViewModel { Id = p.PRODUCT_ID, name = p.PRODUCT_NAME };
I made this small subquery to understand why it doesn't work.我做了这个小子查询来理解为什么它不起作用。
SELECT
(SELECT count(1)
FROM PRODUCTS
WHERE PRODUCT_IND_CHANGE != NULL
) AS SYMBOL_OPERATOR1
,(SELECT count(1)
FROM PRODUCTS
WHERE PRODUCT_IND_CHANGE IS NULL
) AS SYMBOL_OPERATOR2
FROM DUAL
is there any way to use "where field is null" in linq or to simulate it?有没有办法在 linq 中使用“where field is null”或模拟它?
librarys:图书馆:
UPDATE 1:更新 1:
I just checked the log, and it's printing the following when transforming to pl sql code刚刚查看了日志,转换为pl sql代码时打印如下
2022-10-06 17:36:53.0309|DEBUG|Microsoft.EntityFrameworkCore.Query|192.168.1.15|Generated query execution expression:
'queryContext => new SingleQueryingEnumerable<ProductViewModel>(
(RelationalQueryContext)queryContext,
RelationalCommandCache.SelectExpression(
Projection Mapping:
Id -> 0
Name -> 1
SELECT s.PRODUCT_ID AS Id, s.PRODUCT_NAME AS Name
FROM PRODUCT AS s
WHERE s.PRODUCT_IND_CHANGE == NULL),
Func<QueryContext, DbDataReader, ResultContext, SingleQueryResultCoordinator, ProductViewModel>,
API.SGA.Products.Data.DbContext,
False,
False,
True
)'|
did you try你试过了吗
where p.PRODUCT_IND_CHANGE.Equals(null)
in Linq?在 Linq?
In SQL it should be在SQL应该是
WHERE PRODUCT_IND_CHANGE IS NOT NULL
Is your class's "PRODUCT_IND_CHANGE" attribute nullable?您班级的“PRODUCT_IND_CHANGE”属性是否可以为空? Something like就像是
public int? PRODUCT_IND_CHANGE {get; set; }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.