Fix: Apply variant loading workaround to GetProductByIdAsync
This commit is contained in:
parent
7dbdc0d46f
commit
0e8b53df01
@ -188,11 +188,16 @@ public class ProductService : IProductService
|
|||||||
.Include(p => p.Category)
|
.Include(p => p.Category)
|
||||||
.Include(p => p.Photos)
|
.Include(p => p.Photos)
|
||||||
.Include(p => p.MultiBuys)
|
.Include(p => p.MultiBuys)
|
||||||
.Include(p => p.Variants)
|
|
||||||
.FirstOrDefaultAsync(p => p.Id == id);
|
.FirstOrDefaultAsync(p => p.Id == id);
|
||||||
|
|
||||||
if (product == null) return null;
|
if (product == null) return null;
|
||||||
|
|
||||||
|
// Manually load variants - using fresh query to avoid Contains() json_each bug in EF Core 9 + SQLite
|
||||||
|
var variants = await _context.ProductVariants
|
||||||
|
.Where(v => v.ProductId == id && v.IsActive)
|
||||||
|
.OrderBy(v => v.SortOrder)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
return new ProductDto
|
return new ProductDto
|
||||||
{
|
{
|
||||||
Id = product.Id,
|
Id = product.Id,
|
||||||
@ -231,7 +236,7 @@ public class ProductService : IProductService
|
|||||||
CreatedAt = v.CreatedAt,
|
CreatedAt = v.CreatedAt,
|
||||||
UpdatedAt = v.UpdatedAt
|
UpdatedAt = v.UpdatedAt
|
||||||
}).ToList(),
|
}).ToList(),
|
||||||
Variants = product.Variants.OrderBy(v => v.SortOrder).Select(v => new ProductVariantDto
|
Variants = variants.Select(v => new ProductVariantDto
|
||||||
{
|
{
|
||||||
Id = v.Id,
|
Id = v.Id,
|
||||||
ProductId = v.ProductId,
|
ProductId = v.ProductId,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user