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.

Muhammad Imran AnsariPosted Feb 9, 2022, 11:19 AM
Tamil RkPosted Feb 9, 2022, 11:04 AM
Muhammad Imran AnsariPosted Feb 9, 2022, 10:47 AM
You can achieve this using Dapper. Dapper provide extensible extension query method that can be called from any object of type IDbConnection. It can execute a query and map the result. For more information and help follow the link:
https://dapper-tutorial.net/query