title: Using multiple IF statements in stored procedure with different parameters call on Linq C#
body: <p>Is it possible to use a stored procedure in c# because I've tried it on VB.net when I can setup its parameters that only needed let's say I have a stored procedure like this: </p>
  
  <pre><code>    ALTER PROC [dbo].[StoreProcedure_Test01]
      (    
          @Param01 nvarchar(35) = NULL,
          @Param02  smallint = NULL,
          @Param03 char(21) = NULL,
          @Param04 datetime = NULL,       
          @Type bigint
      )    
      WITH EXECUTE AS CALLER
      AS
      BEGIN    
      SET NOCOUNT ON;        
      BEGIN TRY    
          BEGIN TRANSACTION;
          IF @Type =1
          BEGIN
            SELECT Col1, Col2, Col3 From TABLE00 Col00 = @Param2           
          END
          IF @Type = 2
          BEGIN
            Select * FROM TABLE01 where Col01 = @Param1 and Col04 = @Param03
          END
  END
  </code></pre>
  
  <p>Now in my C# Codes calling out store procedures I do like this:</p>
  
  <pre><code>var query = (from i in LinQ.StoreProcedure_Test01(Param01, Param02, Param03, Param04, 1) where i.Col00 == 1 select new { AA = i.Param01, AB = i.Param02 });
  </code></pre>
  
  <p>Now on the parameters I place a 1 for the if statement in the stored procedure the problem is that if I select it in gave me the 1st if statement return data only now if I do like this: </p>
  
  <pre><code>var query = (from i in LinQ.StoreProcedure_Test01(Param01, Param02, Param03, Param04, 2) where i.Col00 == 1 select new { "ALL TABLE" });
  </code></pre>
  
  <p>put an 1 parameter for the if statement in stored procedure it still gave me the same return data from the 1st if statement and it ignores the second if statement is there a way I can use a stored procedure for c# with multiple condition and parameters needed specially when I use a virtual table it also ignores it. is it possible?</p>
  
  <p>Just to add up some of my prev deeds i tried doing this on vb.net by using ado.net framework.</p>
  
  <pre><code>Try
              cmd = New SqlCommand
              da = New SqlDataAdapter
  
              cmd.Connection = con
              cmd.CommandText = "[StoreProcedure_Test01]" 'this is your store procedure
              cmd.CommandType = CommandType.StoredProcedure
  
              With cmd
  
                  .Parameters.Add(New SqlParameter("@Param01", SqlDbType.NVarChar))
                  .Parameters("@Param01").Direction = ParameterDirection.Input
                  .Parameters("@Param01").Value = Parameter01
  
                  .Parameters.Add(New SqlParameter("@Param02", SqlDbType.NVarChar))
                  .Parameters("@Param02").Direction = ParameterDirection.Input
                  .Parameters("@Param02").Value = Parameter02
  
                  .Parameters.Add(New SqlParameter("@Param03", SqlDbType.NVarChar))
                  .Parameters("@Param03").Direction = ParameterDirection.Input
                  .Parameters("@Param03").Value = Parameter03
  
                  .Parameters.Add(New SqlParameter("@Param04", SqlDbType.NVarChar))
                  .Parameters("@Param04").Direction = ParameterDirection.Input
                  .Parameters("@Param04").Value = Parameter04
  
                  .Parameters.Add(New SqlParameter("@Type", SqlDbType.Int))
                  .Parameters("@Type").Direction = ParameterDirection.Input
                  .Parameters("@Type").Value = 1
  
              End With
              cmd.ExecuteNonQuery()
              Return True
  
          Catch ex As Exception
              MsgBox(ex.Message)
          Finally
              cmd.Dispose()
          End Try
  </code></pre>
  
  <p>as seen above its flexible coz i can add parameters as same as the store procedure conditions i've made all i want to know is that when it comes to c# linq is it possible to do this? :(</p>