1

I have a stored procedure in SQL as below:

CREATE PROCEDURE USP_Select
    (@id INT)
AS
    SELECT * FROM EMO;
    SELECT * FROM student WHERE id = @id;
    SELECT * FROM tbl1;

    RETURN 0

I am getting data using Entity Framework from that stored procedure using this code:

Modalities context = new Modalities();
context.USP_Select(1);

How can I define which table data gets in my code?

So here how can I get data different tables in code from the stored procedure?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
jai pundir
  • 49
  • 3

2 Answers2

0

first, add your stored procedure in .edmx file and create a complex type for that stored procedure and you can use an entity. Use the following link to create complex type

Adding stored procedures complex types in Entity Framework

Sunny Jangid
  • 578
  • 4
  • 19
0

Cant you just pass a parameter to select which table you wanna get data from?

CREATE PROCEDURE USP_Select
   @table varchar(50),
   @id INT = NULL
    AS
    BEGIN

     IF @table = "EMO" 
     BEGIN 
        SELECT * FROM EMO;
     END
     ELSE IF @table = "student"
     BEGIN
        SELECT * FROM student WHERE id = @id;
     END
     ELSE IF @table = "tal1"
     BEGIN
        SELECT * FROM tbl1;
     END


END
imanshu15
  • 734
  • 3
  • 21