Questions tagged [fromsqlraw]

6 questions
0
votes
1 answer

Dynamic sub Select using Expression with FromSqlRaw in .Net Core (v7) with cast to Entity EF (Ex: The required column not present of 'FromSql')

This is simplified example of what is needed. Could this somehow be made to work? Entity: public class Entry { public int EntryId { get; set; } public string Name { get; set; } = null!; public string? Description { get; set;…
borisdj
  • 2,201
  • 3
  • 24
  • 31
0
votes
0 answers

Asynchronous FromRawSql to call a stored procedure that returns a single record in EF Core 6

I just found this way to call a stored procedure that returns a single record but I have to do it synchronously If I try to do it asynchronously using FromRawSql().FirstOrDefault() I get this error: "Employee" does not contain a definition for…
kintela
  • 1,283
  • 1
  • 14
  • 32
0
votes
0 answers

Not able to add FromSqlRaw or FromSqlRawAsync in Web API code

I am using VS 2019 and I have a simple Web API method to execute a stored procedure that returns one string. I am using Entity Framework Core version 3.1.31. When I am trying to call the stored procedure in my Web API method by…
0
votes
1 answer

Error executing stored procedure with FromSqlInterpolated in ASP.NET Core 6 with EF Core 6

I have in my SQL Server this stored procedure with a single parameter and that returns a single record. When I call it like this: public async Task GetEmpleado(string codigoSAP) { var empleado = await _context.Empleados …
kintela
  • 1,283
  • 1
  • 14
  • 32
0
votes
2 answers

Execute custom SQL before running FromSqlRaw in Entity Framework Core 6 or above in SQL Server

I only need it to work for SQL Server. This is an example. The question is about a general approach. There is a nice extension method from https://entityframework-extensions.net called WhereBulkContains. It is, sort of, great, except that the code…
0
votes
1 answer

Entity Framework Core error on temporary table when FromSqlRaw invoques COUNT(*)

I'm using the below query in .NET Core 6. If I use anything other than ToList() I get Incorrect syntax near the keyword 'INTO'. Incorrect syntax near ')'.. This only happens when I use COUNT(*). If anyone can tell me why, I would appreciate. …
Daniel Lobo
  • 2,144
  • 1
  • 13
  • 6