0

I am creating a web app using web api mvc and I am using dapper.

Here is a scenario where I want to get the data in a list by validating user info

DynamicParameters param = new DynamicParameters();
param.Add("@fname", std.Fname);
param.Add("@lname", std.Lname);
param.Add("@action", "L");
IList<student> studlist = SqlMapper.Query<student>(con, "Stud_IUDV", param).ToList();
return studlist.ToList();

Here I want to get the data by validating these params and my storedprocedure looks like

if(@action='L')
//validation with select command

else
//select all data

and I am suppose to get

(validation with select command)

but else part of my storedprocedure is executing

What is wrong in my code?

Hemanth Vatti
  • 85
  • 1
  • 8

1 Answers1

0
IF(@action='L')
  BEGIN
    //validation with select command
  END
ELSE
  BEGIN
    //select all data
  END

This will solve your sql problem.

Paul Roub
  • 36,322
  • 27
  • 84
  • 93