How to pass in sql "like" condition from c# with single quotes
<p>I have string variable in c#</p>

<pre><code>String Condition = " And LoginName like ''%"+txtLoginName.text+"%''";
</code></pre>

<p>I pass this condition variable to a stored procedure like this:</p>

<pre><code>SqlCommand cmd = new SqlCommand();
cmd.CommandText = "GetAllUserMasterBySearch";
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Condition ", Condition );
</code></pre>

<p>And my stored procedure is here:</p>

<pre><code>create PROCEDURE [dbo].[GetAllUserMasterBySearch] (  
    @Condition nvarchar(max)  
    ) 
as
    declare @Query  nvarchar(max) 

    set @Query = 'SELECT
                      [UserMasterId], [LoginName], [UserName],
                      [UserType], [MobileNo], [Email],
                      [IsLogin], [IpAddress]
                  FROM  
                      UserMaster      
                  WHERE 
                      IsActive = 1 ' + @Condition

    print @query   

    EXEC sp_executesql @Query
</code></pre>

<p>How to pass "like" condition from C# ?</p>