There is a code for creating function
CREATE FUNCTION GetMaxNoteId(User_id bigint)
RETURNS bigint
as
$$
select greatest(
(select max(noteid) from spending where userid = User_id),
(select max(noteid) from income where userid = User_id))
$$ LANGUAGE SQL;
i tried to use something like this
var a = db.Database.ExecuteSqlRaw($"select GetMaxNoteId({ChatId}) as noteid");
but it doesn't work correctly enter image description here
may be have i to use directly SQL in Ado.net like
NpgsqlConnection conn = new NpgsqlConnection(db.Database.GetConnectionString());
NpgsqlCommand cmd = new NpgsqlCommand($"select GetMaxNoteId({ChatId}) as noteid", conn);
conn.Open();
long GG = (long)cmd.ExecuteScalar();
conn.Close();
conn.Dispose();
i also tried alternative query with using EF however it doesn't work too