Sushant Torankar

Sushant Torankar

  • 1.4k
  • 226
  • 23.2k

About FromSqlRaw function in web api

May 24 2022 12:54 PM


I am using core web api ani sql server in my project

Following is my code to get all users :

 public async Task<List<UserMaster>> GetAllUsers()
            var users = await _usersContext
             .FromSqlRaw("exec uspGetAllUsers")

            return users;


it works fine,but I have to mention all columns of UsrMaster table in uspGetAllUsers procedure

I don't want to mention unnecessary columns in sql stored procedure

For ex, If Usermaster table has 10 columns , I have to mention all 10 columns in stored procedure, wheere as I just want to bind 4 columns in procedure

how to achieve this ?


Thank you

Answers (3)