1.Sql中的 in 写法
Select ProductID, ProductName, CategoryID
From dbo.Products
Where CategoryID in (1, 2);
2.Sql中的 not in 写法
Select ProductID, ProductName, CategoryID
From dbo.Products
Where CategoryID not in (1, 2);
3.Linq中 in 的写法
public class CoalBillState
{
public static CoalBillStateEnum[] UncompleteArray = new CoalBillStateEnum[]
{
CoalBillStateEnum.未完成,
CoalBillStateEnum.装车已出库,
CoalBillStateEnum.装车已回皮,
CoalBillStateEnum.锁定,
CoalBillStateEnum.卸车已称重
};
}
var creditCardSendingOrder = await _creditCardRepository.FirstOrDefaultAsync(x => x.VehicleCode == code && x.LicensePlateCode == plateNumber && (CoalBillState.UncompleteArray.Contains(x.CoalBillState)));
解析成Sql后为
SELECT [t0].[ProductID], [t0].[ProductName], [t0].[SupplierID], [t0].[CategoryID], [t0].[QuantityPerUnit], [t0].[UnitPrice], [t0].[UnitsInStock], [t0].[UnitsOnOrder], [t0].[ReorderLevel], [t0].[Discontinued]
FROM [dbo].[Products]AS [t0]
WHERE [t0].[State] IN (@p0, @p1)