This SQL was generated when you pass a parameter from a variable
SELECT
..
FROM ( SELECT TOP (1)
..
FROM (SELECT ..
FROM [dbo].[PurchaseOrders] AS [Extent1]
INNER JOIN [dbo].[Parameters] AS [Extent2] ON [Extent1].[StatusId] = [Extent2].[Id]
WHERE [Extent1].[Deleted] <> 1 ) AS [Filter1]
INNER JOIN [dbo].[Suppliers] AS [Extent3] ON [Filter1].[SupplierId] = [Extent3].[Id]
WHERE ([Filter1].[Id1] = @p__linq__0) AND ([Filter1].[LocationId] = @p__linq__1)
) AS [Limit1]
While if you pass a constant the generated SQL is much simpler
SELECT
..
FROM ( SELECT TOP (1)
..
FROM [dbo].[PurchaseOrders] AS [Extent1]
INNER JOIN [dbo].[Parameters] AS [Extent2] ON [Extent1].[StatusId] = [Extent2].[Id]
INNER JOIN [dbo].[Suppliers] AS [Extent3] ON [Extent1].[SupplierId] = [Extent3].[Id]
WHERE ([Extent1].[Deleted] <> 1) AND (2 = [Extent1].[LocationId]) AND ([Extent1].[Id] = @p__linq__0)
) AS [Limit1]
so, how can we tell EF to generate 2nd SQL without using constant?