Need some help with my end-point
So i have this end point:
My model:
The query works fine in mssql, some of the data is indeed NULL, my guess would be that calling the below function on that data gives the error?
This is the error im getting:
This is my first Dotnet project so all tips and hints are welcome!
c++
{
[Route("[controller]")]
[ApiController]
public class StepController : ControllerBase
{
private readonly DataContext _context;
public StepController(DataContext context)
{
_context = context;
}
[HttpGet]
public async Task<ActionResult<List<Step>>> Get(string databaseName, int workflowKey)
{
string query = "SQLQUERY";
// some of the data is indeed NULL, my guess would be that calling the below function on that data gives the error?
var steps = await _context.steps.FromSqlRaw(query).ToListAsync();
return Ok(steps);
}
}c++
{
[Route("[controller]")]
[ApiController]
public class StepController : ControllerBase
{
private readonly DataContext _context;
public StepController(DataContext context)
{
_context = context;
}
[HttpGet]
public async Task<ActionResult<List<Step>>> Get(string databaseName, int workflowKey)
{
string query = "SQLQUERY";
// some of the data is indeed NULL, my guess would be that calling the below function on that data gives the error?
var steps = await _context.steps.FromSqlRaw(query).ToListAsync();
return Ok(steps);
}
}My model:
c++
public class Step
{
[Key]
public int Key { get; set; }
public string Type { get; set; }
public int ParentKey { get; set; }
public string SubWorkflowCode { get; set; }
public int Sequence { get; set; }
public int WorkflowKey { get; set; }
[NotMapped]
public List<Parameters> Parameters { get; set; }
}
public class Parameters
{
public string Name { get; set; }
public string Source { get; set; }
public string Value { get; set; }
}c++
public class Step
{
[Key]
public int Key { get; set; }
public string Type { get; set; }
public int ParentKey { get; set; }
public string SubWorkflowCode { get; set; }
public int Sequence { get; set; }
public int WorkflowKey { get; set; }
[NotMapped]
public List<Parameters> Parameters { get; set; }
}
public class Parameters
{
public string Name { get; set; }
public string Source { get; set; }
public string Value { get; set; }
}The query works fine in mssql, some of the data is indeed NULL, my guess would be that calling the below function on that data gives the error?
c++
var steps = await _context.steps.FromSqlRaw(query).ToListAsync();c++
var steps = await _context.steps.FromSqlRaw(query).ToListAsync();This is the error im getting:
System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.This is my first Dotnet project so all tips and hints are welcome!