将不在查询中与日期范围过滤器合并将结果归零

时间:2019-07-16 20:48:20

标签: c# sql linq-to-sql repository

查询以了解日期范围之间没有特定状态的订单将返回零结果

Linq To SQL

  string[] notHavingStaus = { "CantFind", "Review" };

_repository.Query<Entities.Order>()
            .Where(x => (!notHavingStaus.Contains(x.ApplicationStatus))
            && x.OrderDate >= fromdate && x.OrderDate <= todate);

生成的查询

/****** Script for SelectTopNRows command from SSMS  ******/
SELECT *
  FROM [dbo].[Order]
  Where (not ApplicationStatus in ('CantFind' , 'Review')) and
     (OrderDate>='2019-07-16' and OrderDate<='2019-07-17')

0 个答案:

没有答案