Tamil Rk

Tamil Rk

  • 1.3k
  • 451
  • 17.6k

how to get json result in function call in ef core postgresql

Feb 9 2022 9:06 AM

I have created the function in PostgreSQL database

example function:

CREATE FUNCTION find_val(val text) 
RETURNS json AS
$$
SELECT row_to_json(sample) FROM sample where $1 = ANY(col4);
$$ LANGUAGE sql;

 I'm, getting JSON result.

How to execute the function on npgsql EF core?

In below execute method, I'm using item model, but my actual function has multiple tables collaboration and returning JSON result, how to execute without a model in EF core.

Example:

_context.item.FromSqlRaw("select * from log.fn_apiItemo('"+ MobileNumber + "')");

Please suggest any way to resolve this method in EF core. 

Thanks.


Answers (3)