none
Should I be concerned and if yes, any suggestions? RRS feed

  • Discussão Geral

  • Hi everybody,

    I am using SQL Profiler to see the SQL generated by EF and I see the following as part of the query:

    SELECT 
        [Extent1].[ItemId] AS [ItemId], 
        [Extent1].[Item] AS [Item], 
        [Extent1].[ItemDescription] AS [ItemDescription], 
        [Extent1].[CategoryId] AS [CategoryId], 
        [Extent1].[Category] AS [Category], 
        [Extent1].[DepartmentId] AS [DepartmentId], 
        [Extent1].[Department] AS [Department], 
        [Extent1].[RuleId] AS [RuleId], 
        [Extent1].[RuleDescription] AS [RuleDescription], 
        [Extent1].[Hidden] AS [Hidden]
        FROM [dbo].[SiriusV_PaymentPlanItems] AS [Extent1]
        WHERE ( NOT ([Extent1].[ItemId] IN (440, 1017))) AND (-1 = [Extent1].[ItemId]) AND (0 = [Extent1].[Hidden])
        ORDER BY [Extent1].[Department] ASC


    I'm concerned about NOT IN part which doesn't use any parameters. My C# code uses this

    var list = _dbSetList.AsQueryable();
                if (idsToExclude != null)
                {
                    list = list.Where(item => !idsToExclude.Contains(item.ItemId));
                }

    My question is - does it matter much? Is there a better way (I'd prefer to get minimum modifications if possible) to get my final query generated with parameters when I use the list of integers? Should I somehow use a different approach to filter my list by Ids to exclude?

    Thanks in advance.


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


    My TechNet articles

    • Tipo Alterado Naomi NModerator quarta-feira, 5 de fevereiro de 2020 12:37 No clear answer
    quarta-feira, 22 de janeiro de 2020 13:43
    Moderador

Todas as Respostas