54 lines
1.3 KiB
C#
54 lines
1.3 KiB
C#
using CH.Dal;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using OpenHarbor.CQRS.Abstractions;
|
|
using PoweredSoft.DynamicLinq;
|
|
|
|
namespace CH.CQRS.Query.EnergyProvider;
|
|
|
|
public class EnergyProviderQuery
|
|
{
|
|
|
|
}
|
|
|
|
public class EnergyProviderQueryItem
|
|
{
|
|
public long Id { get; set; }
|
|
|
|
public string Name { get; set; } = null!;
|
|
|
|
public bool Active { get; set; }
|
|
|
|
public DateTime? DisabledAt { get; set; }
|
|
|
|
public DateTime CreatedAt { get; set; }
|
|
|
|
public DateTime? UpdatedAt { get; set; }
|
|
}
|
|
|
|
public class EnergyProviderQueryParams
|
|
{
|
|
|
|
}
|
|
public class EnergyProviderQueryableProvider(CHDbContext dbContext) : IQueryableProviderOverride<EnergyProviderQueryItem>
|
|
{
|
|
public async Task<IQueryable<EnergyProviderQueryItem>> GetQueryableAsync(object query, CancellationToken cancellationToken = default)
|
|
{
|
|
var queryable = dbContext.EnergyProviders
|
|
.AsNoTracking()
|
|
.AsQueryable();
|
|
|
|
var result = queryable
|
|
.Select(energyProvider => new EnergyProviderQueryItem
|
|
{
|
|
Id = energyProvider.Id,
|
|
Name = energyProvider.Name,
|
|
Active = energyProvider.Active,
|
|
DisabledAt = energyProvider.DisabledAt,
|
|
CreatedAt = energyProvider.CreatedAt,
|
|
UpdatedAt = energyProvider.UpdatedAt
|
|
})
|
|
.OrderBy(energyProvider => energyProvider.Id);
|
|
|
|
return result;
|
|
}
|
|
} |