How can we define complex type for a stored procedure that accepts dynamic query as input [edmx]

StackOverflow https://stackoverflow.com/questions/19997671

  •  30-07-2022
  •  | 
  •  

Pergunta

I have a stored procedure like this

create proc usp_ProjectName_DBQuery
    @strDBQuery varchar(8000)
as
begin
   exec (@strDBQuery)
end

So this will accept any DBQuery and it will execute it in the server.

Now my problem is this will return n number of columns based on the query.

For example if I pass in select x,y from db it will return two columns, but if i pass in select * from db it will return n columns, it sometimes may not return anything

So how can I define a complex type for this stored procedure!? Please help

Foi útil?

Solução

@marc_s is right this is not something you can do in EF (without third party library). Entity framework doesn't really like that. You have 2 options:

  1. Use ADO.NET instead as suggested in the comments

  2. Change your stored procedure to return the same number of column even of they are empty fields.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top