I develop a web application with clean architecture. So my context database in persistence app and endpoint (ASP.NET Core MVC app) access to database with an interface in application layer.
I want map a method to a SQL function in my Oracle database. In case I have only a single ASP.NET Core MVC app there is a document in link and everything is OK.
But I don’t know how can configure it in CLEAN Architecture.
DataBaseContext class
[DbFunction("AddTwoNum ", " MySchema ")]
public string AddTwoNum (int? a, int? b)
{
throw new NotImplementedException();
}
OnModelCreating:
modelBuilder.HasDefaultSchema("MySchema");
modelBuilder.HasDbFunction(typeof(DataBaseContext).GetMethod(nameof(AddTwoNum), new[] { typeof(int), typeof(int) }));
IDataBaseContext interface:
string AddTwoNum(int? a, int? b);
In my ASP.NET Core MVC app:
var query = from b in _context.MyTable
select b,
name = _context.AddTwoNum (b.AField, b.BField),;
When I run a query in my ASP.NET Core MVC app, it generates an exception and run this line map function in DataBaseContext
throw new NotImplementedException();
select new { b, Some = _context.AddTwoNum (b.AField, b.BField) }