I have a problem with inserting values from a SQL table (pgadmin) to a web application. If I check my table in pgadmin, all is ok:
But if I push it into application on Azure, it returns only:
I don't know where the problem is.
display.data.razor:
@page "/displaydata"
@using WebApplication1.Data;
@using WebApplication1.Services;
@inherits OwningComponentBase<DataService>
<h1>Display data</h1>
<table border="1">
<tr>
<th>
id
</th>
<th>
Nazov IMG
</th>
<th>
label
</th>
</tr>
@foreach (WebApplication1.Data.Dataset item in sc)
{
<tr>
<td>@item.relid</td>
<td>@item.name</td>
<td>@item.label</td>
</tr>
}
</table>
@code {
public System.Collections.Generic.IList<Dataset> sc;
protected override void OnInitialized()
{
sc = Service.displaydata();
foreach (var item in sc)
{
Console.Write(@item.relid + " " + @item.label);
}
}
}
Result of Console.Write(@item.relid + " " + @item.label):
2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)2 "Gold(99.64134)
DataService:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebApplication1.Data;
namespace WebApplication1.Services
{
public class DataService
{
protected readonly ApplicationDbContext _dbcontext;
public DataService(ApplicationDbContext _db)
{
_dbcontext = _db;
}
public List<Dataset> displaydata()
{
return _dbcontext.results.ToList();
}
}
}
Data:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace WebApplication1.Data
{
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
{
}
public DbSet<Dataset> results { get; set; }
}
}



