I have a scalar function in a database that returns string value and I want to fetch this value at the server-side through LINQ. PS. The application I am developing is in .Net Core.
I tried different ways that are available over the internet to achieve this but found no luck.
Below are the links which I tried implementing
- http://anthonygiretti.com/2018/01/11/entity-framework-core-2-scalar-function-mapping/
- https://forums.asp.net/t/2055038.aspx?scalar+function+entity+framework
- Entity Framework Code-First Execute Scalar-Valued Functions
First try:
var query = _context.StringValue.Select(d => Context.GetDetail(form.ValueString, "State"));
string x = query.FirstOrDefault();
Second try:
IQueryable<UDFResult> state = _context.Query<UDFResult>().FromSql($"select dbo.GetDetail('{form.ValueString}','State') AS value");
List<UDFResult> l = state.ToList();
Any help will be appreciated and also I would be interested in seeing an example of how to achieve this.