none
Entity SQL IN/Multiset issue RRS feed

  • Question

  • I am using the following query in entity sql

    Select n.Name as NodeNameN from Nodes as n where n.Name IN MultiSet (@Test) 
    :
    The value is substitued at runtime using the below code 
    
    var reader = model.CreateQuery<System.Data.Common.DbDataRecord>(                 Statement,                 Parameters.ToArray()); 
    
    
    


    When this is executed, the corresponding statment generated in sql server is as below :

    exec sp_executesql N'SELECT  1 AS [C1],  [Extent1].[Name] AS [Name] FROM [dbo].[Nodes] AS [Extent1] WHERE [Extent1].[Name] = @Test',N'@Test nvarchar(4000)',@Test=N'''BMA'',''Area A'','

    Instead of "IN" Clause the "=" clause is substituted.

    Am I doing any thing wrong here.

    When this is executed, the corresponding statment generated in sql server is as below :

    exec sp_executesql N'SELECT  1 AS [C1],  [Extent1].[Name] AS [Name] FROM [dbo].[Nodes] AS [Extent1] WHERE [Extent1].[Name] = @Test',N'@Test nvarchar(4000)',@Test=N'''BMA'',''Area A'','

    Instead of "IN" Clause the "=" clause is substituted.

    Am I doing any thing wrong here.

    Wednesday, January 4, 2012 1:51 PM

Answers

  • Hi tourams,

    Welcome to MSDN Forum.

    Is there only one parameter in your MultiSet? If it is, it certainly will generate a '=' instead of 'IN'. If you want to generate 'IN' key word in your query statement, just add more parameters in your MultiSet.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Friday, January 6, 2012 3:45 AM
    Moderator