denis-ivanov / EntityFrameworkCore.ClickHouse

ClickHouse provider for Entity Framework Core.
https://clickhouse.tech/
23 stars 5 forks source link

Incorrect data when get data #59

Open navnforfun opened 2 months ago

navnforfun commented 2 months ago

I had successfull scaffold model by EntityFrameworkCore.ClickHouse package and I use this code to get data from my clickhouse database

[HttpGet]
public async Task<ActionResult<IEnumerable<User>>> GetUsers()
{
    return await _context.Users.OrderBy(u => u.Timestamp).ToListAsync();
}

The result was

[ { "id": 1, "name": "Clickhouse first", "timestamp": "2024-09-21T10:15:35Z" }, { "id": 1, "name": "Clickhouse first", "timestamp": "2024-09-21T10:15:35Z" }, { "id": 0, "name": "string", "timestamp": "2024-09-21T10:24:11Z" }, { "id": 0, "name": "string", "timestamp": "2024-09-21T10:24:11Z" }, { "id": 0, "name": "string", "timestamp": "2024-09-21T10:24:11Z" }, { "id": 0, "name": "string", "timestamp": "2024-09-21T10:24:11Z" }, { "id": 0, "name": "string", "timestamp": "2024-09-21T10:24:11Z" } ]

My real data was

id name timestamp 0 hello world 2024-09-21 11:53:01 0 third 2024-09-21 11:53:46 0 hello world 2024-09-21 11:53:01 0 string 2024-09-21 10:24:11 1 Clickhouse first 2024-09-21 10:15:35 1 Clickhouse second 2024-09-21 10:15:35

denis-ivanov commented 2 months ago

Please, attach all scripts and command line commands

navnforfun commented 2 months ago

@denis-ivanov
program.cs

//Add services to the container.
builder.Services.AddDbContext<MyDbContext>(options =>
{
    options.UseClickHouse();
});

The file MyDbContext.csI generated by this : dotnet ef dbcontext scaffold "Host=127.0.0.1;Port=8123;User=default;Password=;Database=db2;Compress=True;CheckCompressedHash=False;SocketTimeout=60000000;Compressor=lz4" EntityFrameworkCore.ClickHouse -o Models -c MyDbContext

The file UserController.csI scaffolded by VS 2022 feature

 private readonly MyDbContext _context;

 public UsersController(MyDbContext context)
 {
     _context = context;
 }

 // GET: api/Users
 [HttpGet]
 public async Task<ActionResult<IEnumerable<User>>> GetUsers()
 {
     return await _context.Users.OrderBy(u => u.Timestamp).ToListAsync();
 }

This is the repo of my project: https://github.com/userforfun201/Clickhouse2Net

navnforfun commented 2 months ago

@denis-ivanov Can my bug I encountered be fixed?

navnforfun commented 1 month ago

@denis-ivanov Am I wrong somewhere? Could you guide me? Any help would be appreciated.