C
C#•12mo ago
fromliberty

my response

why my response coming like this weirdly, all $ stuff and so on
No description
79 Replies
Angius
Angius•12mo ago
How are you returning this response?
fromliberty
fromlibertyOP•12mo ago
hmm I have ProductRepository, and Mapper configs example code from repository:
public async Task<IEnumerable<ProductDto>> GetProducts()
{
var productList = await _db.Products
.Include(x => x.LabelProducts)
.Include(x => x.Colours)
.Include(x => x.Rating)
.ToListAsync();
return _mapper.Map<List<ProductDto>>(productList);
}
public async Task<IEnumerable<ProductDto>> GetProducts()
{
var productList = await _db.Products
.Include(x => x.LabelProducts)
.Include(x => x.Colours)
.Include(x => x.Rating)
.ToListAsync();
return _mapper.Map<List<ProductDto>>(productList);
}
`
Angius
Angius•12mo ago
Ooooof Well, the code is bad, but it shouldn't result in any names starting with $ Unless ProductDto has some [JsonPropertyName] attribute on the ID or something
fromliberty
fromlibertyOP•12mo ago
well ProductDto looks like this:
public class ProductDto
{
public int ProductId { get; set; }
public string Name { get; set; }
public double Price { get; set; }
public string Description { get; set; }
public string CategoryName { get; set; }
public string ImageUrl { get; set; }
public string HoverImageUrl { get; set; }
public ICollection<LabelProductDto> LabelProducts { get; set; }
public RatingDto Rating { get; set; }
public ICollection<Colour> Colours { get; set; }
}
public class ProductDto
{
public int ProductId { get; set; }
public string Name { get; set; }
public double Price { get; set; }
public string Description { get; set; }
public string CategoryName { get; set; }
public string ImageUrl { get; set; }
public string HoverImageUrl { get; set; }
public ICollection<LabelProductDto> LabelProducts { get; set; }
public RatingDto Rating { get; set; }
public ICollection<Colour> Colours { get; set; }
}
also labels comes null in response as well, there is another problem lol
Angius
Angius•12mo ago
Huh, dunno where $id comes from then How do you return the response itself?
fromliberty
fromlibertyOP•12mo ago
hmm i think like this:
[HttpGet]
public async Task<object> Get()
{
try
{
IEnumerable<ProductDto> productDtos = await _productRepository.GetProducts();
_response.Result = productDtos;
}
catch (Exception ex)
{
_response.IsSuccess = false;
_response.ErrorMessages
= new List<string>() { ex.ToString() };
}
return _response;
}
[HttpGet]
public async Task<object> Get()
{
try
{
IEnumerable<ProductDto> productDtos = await _productRepository.GetProducts();
_response.Result = productDtos;
}
catch (Exception ex)
{
_response.IsSuccess = false;
_response.ErrorMessages
= new List<string>() { ex.ToString() };
}
return _response;
}
Angius
Angius•12mo ago
If so, then no idea where the $s are coming from
fromliberty
fromlibertyOP•12mo ago
oh i also have responsedto
public class ResponseDto
{
public bool IsSuccess { get; set; } = true;
public object Result { get; set; }
public string DisplayMessage { get; set; } = "";
public List<string> ErrorMessages { get; set; }
}
public class ResponseDto
{
public bool IsSuccess { get; set; } = true;
public object Result { get; set; }
public string DisplayMessage { get; set; } = "";
public List<string> ErrorMessages { get; set; }
}
Angius
Angius•12mo ago
That object is sus Avoid it like the plague
fromliberty
fromlibertyOP•12mo ago
and also label doesnt coming as well lol oh lol
Angius
Angius•12mo ago
If you want a generic Response type, make it... generic
public class ResponseDto<T>
{
public bool IsSuccess { get; set; } = true;
public T Result { get; set; }
public string DisplayMessage { get; set; } = "";
public List<string> ErrorMessages { get; set; }
}
public class ResponseDto<T>
{
public bool IsSuccess { get; set; } = true;
public T Result { get; set; }
public string DisplayMessage { get; set; } = "";
public List<string> ErrorMessages { get; set; }
}
Still, I don't think that'd be an issue
fromliberty
fromlibertyOP•12mo ago
yeah 😄 maybe due to seeded data
modelBuilder.Entity<Colour>()
.HasOne(c => c.Product)
.WithMany(p => p.Colours)
.HasForeignKey(c => c.ProductId);

modelBuilder.Entity<LabelProduct>().HasData(new LabelProduct
{
LabelProductId = 1, LabelId = 1, ProductId = 1
});

modelBuilder.Entity<Product>().HasData(new Product
{
ProductId = 1,
Name = "Green Dress For Woman",
Price = 15,
Description = "Praesent scelerisque, mi sed ultrices condimentum, lacus ipsum viverra massa, in lobortis sapien eros in arcu. Quisque vel lacus ac magna vehicula sagittis ut non lacus.<br/>Sed volutpat tellus lorem, lacinia tincidunt tellus varius nec. Vestibulum arcu turpis, facilisis sed ligula ac, maximus malesuada neque. Phasellus commodo cursus pretium.",
ImageUrl = "samosa.jpg",
CategoryName = "Appetizer",
HoverImageUrl = ""
});

modelBuilder.Entity<Rating>().HasData(new Rating
{
Id = 1,
Rate = 3.3,
Count = 100,
ProductId = 1
});

modelBuilder.Entity<Label>().HasData(new Label
{
Id = 1,
Name = "Trending"
});

modelBuilder.Entity<Colour>().HasData(new Colour
{
Id = 1,
Img = "",
Name = "green",
Quantity = 3,
ProductId = 1
});

modelBuilder.Entity<Colour>().HasData(new Colour
{
Id = 2,
Img = "",
Name = "red",
Quantity = 2,
ProductId = 1
});
modelBuilder.Entity<Colour>()
.HasOne(c => c.Product)
.WithMany(p => p.Colours)
.HasForeignKey(c => c.ProductId);

modelBuilder.Entity<LabelProduct>().HasData(new LabelProduct
{
LabelProductId = 1, LabelId = 1, ProductId = 1
});

modelBuilder.Entity<Product>().HasData(new Product
{
ProductId = 1,
Name = "Green Dress For Woman",
Price = 15,
Description = "Praesent scelerisque, mi sed ultrices condimentum, lacus ipsum viverra massa, in lobortis sapien eros in arcu. Quisque vel lacus ac magna vehicula sagittis ut non lacus.<br/>Sed volutpat tellus lorem, lacinia tincidunt tellus varius nec. Vestibulum arcu turpis, facilisis sed ligula ac, maximus malesuada neque. Phasellus commodo cursus pretium.",
ImageUrl = "samosa.jpg",
CategoryName = "Appetizer",
HoverImageUrl = ""
});

modelBuilder.Entity<Rating>().HasData(new Rating
{
Id = 1,
Rate = 3.3,
Count = 100,
ProductId = 1
});

modelBuilder.Entity<Label>().HasData(new Label
{
Id = 1,
Name = "Trending"
});

modelBuilder.Entity<Colour>().HasData(new Colour
{
Id = 1,
Img = "",
Name = "green",
Quantity = 3,
ProductId = 1
});

modelBuilder.Entity<Colour>().HasData(new Colour
{
Id = 2,
Img = "",
Name = "red",
Quantity = 2,
ProductId = 1
});
`
Angius
Angius•12mo ago
Unlikely Neither your model nor your DTO have an Id property, it's ProductId
fromliberty
fromlibertyOP•12mo ago
i have ProductId too but response is messy like this:
{
"$id": "1",
"isSuccess": true,
"result": {
"$id": "2",
"$values": [
{
"$id": "3",
"productId": 1,
"name": "Green Dress For Woman",
"price": 15,
"description": "Praesent scelerisque, mi sed ultrices condimentum, lacus ipsum viverra massa, in lobortis sapien eros in arcu. Quisque vel lacus ac magna vehicula sagittis ut non lacus.<br/>Sed volutpat tellus lorem, lacinia tincidunt tellus varius nec. Vestibulum arcu turpis, facilisis sed ligula ac, maximus malesuada neque. Phasellus commodo cursus pretium.",
"categoryName": "Appetizer",
"imageUrl": "samosa.jpg",
"hoverImageUrl": "",
"labelProducts": {
"$id": "4",
"$values": [
{
"$id": "5",
"labelProductId": 1,
"productId": 1,
"labelId": 1,
"product": {
"$ref": "3"
},
"label": null
}
]
},
"rating": {
"$id": "6",
"id": 1,
"rate": 3.3,
"count": 100,
"productId": 1,
"product": {
"$ref": "3"
}
},
"colours": {
"$id": "7",
"$values": [
{
"$id": "8",
"id": 1,
"name": "green",
"img": "",
"quantity": 3,
"productId": 1,
"product": {
"$id": "9",
"productId": 1,
"name": "Green Dress For Woman",
"price": 15,
"description": "Praesent scelerisque, mi sed ultrices condimentum, lacus ipsum viverra massa, in lobortis sapien eros in arcu. Quisque vel lacus ac magna vehicula sagittis ut non lacus.<br/>Sed volutpat tellus lorem, lacinia tincidunt tellus varius nec. Vestibulum arcu turpis, facilisis sed ligula ac, maximus malesuada neque. Phasellus commodo cursus pretium.",
"categoryName": "Appetizer",
"imageUrl": "samosa.jpg",
"hoverImageUrl": "",
"labelProducts": {
"$id": "10",
"$values": [
{
"$id": "11",
"labelProductId": 1,
"productId": 1,
"labelId": 1,
"product": {
"$ref": "9"
},
"label": null
}
]
},
"rating": {
"$id": "12",
"id": 1,
"rate": 3.3,
"count": 100,
"productId": 1,
"product": {
"$ref": "9"
}
},
"colours": {
"$id": "13",
"$values": [
{
"$ref": "8"
},
{
"$id": "14",
"id": 2,
"name": "red",
"img": "",
"quantity": 2,
"productId": 1,
"product": {
"$ref": "9"
}
}
]
}
}
},
{
"$ref": "14"
}
]
}
}
]
},
"displayMessage": "",
"errorMessages": null
}
{
"$id": "1",
"isSuccess": true,
"result": {
"$id": "2",
"$values": [
{
"$id": "3",
"productId": 1,
"name": "Green Dress For Woman",
"price": 15,
"description": "Praesent scelerisque, mi sed ultrices condimentum, lacus ipsum viverra massa, in lobortis sapien eros in arcu. Quisque vel lacus ac magna vehicula sagittis ut non lacus.<br/>Sed volutpat tellus lorem, lacinia tincidunt tellus varius nec. Vestibulum arcu turpis, facilisis sed ligula ac, maximus malesuada neque. Phasellus commodo cursus pretium.",
"categoryName": "Appetizer",
"imageUrl": "samosa.jpg",
"hoverImageUrl": "",
"labelProducts": {
"$id": "4",
"$values": [
{
"$id": "5",
"labelProductId": 1,
"productId": 1,
"labelId": 1,
"product": {
"$ref": "3"
},
"label": null
}
]
},
"rating": {
"$id": "6",
"id": 1,
"rate": 3.3,
"count": 100,
"productId": 1,
"product": {
"$ref": "3"
}
},
"colours": {
"$id": "7",
"$values": [
{
"$id": "8",
"id": 1,
"name": "green",
"img": "",
"quantity": 3,
"productId": 1,
"product": {
"$id": "9",
"productId": 1,
"name": "Green Dress For Woman",
"price": 15,
"description": "Praesent scelerisque, mi sed ultrices condimentum, lacus ipsum viverra massa, in lobortis sapien eros in arcu. Quisque vel lacus ac magna vehicula sagittis ut non lacus.<br/>Sed volutpat tellus lorem, lacinia tincidunt tellus varius nec. Vestibulum arcu turpis, facilisis sed ligula ac, maximus malesuada neque. Phasellus commodo cursus pretium.",
"categoryName": "Appetizer",
"imageUrl": "samosa.jpg",
"hoverImageUrl": "",
"labelProducts": {
"$id": "10",
"$values": [
{
"$id": "11",
"labelProductId": 1,
"productId": 1,
"labelId": 1,
"product": {
"$ref": "9"
},
"label": null
}
]
},
"rating": {
"$id": "12",
"id": 1,
"rate": 3.3,
"count": 100,
"productId": 1,
"product": {
"$ref": "9"
}
},
"colours": {
"$id": "13",
"$values": [
{
"$ref": "8"
},
{
"$id": "14",
"id": 2,
"name": "red",
"img": "",
"quantity": 2,
"productId": 1,
"product": {
"$ref": "9"
}
}
]
}
}
},
{
"$ref": "14"
}
]
}
}
]
},
"displayMessage": "",
"errorMessages": null
}
` for example $values 🤔
Angius
Angius•12mo ago
Yes, that's what I'm talkinmg about. You have ProductId in your models, but the resonse has both ProductId and $id It kinda seems like it numbers the total objects in the JSON for some reason...? Ah I think I see what's going on There are $refs that reference $ids
fromliberty
fromlibertyOP•12mo ago
oh i actually have this: options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.Preserve; but when i deelte this then
Angius
Angius•12mo ago
Yeah
fromliberty
fromlibertyOP•12mo ago
response gives error saying cycle detected
Angius
Angius•12mo ago
Yeah Because you're .Include()ing a bunch instead of doing the mapping on the database, I'd assume Or because you're loading too much data that's referenced cyclically
fromliberty
fromlibertyOP•12mo ago
yeah i want to include everything my data is small for now
Angius
Angius•12mo ago
Not a great idea, but sure, if it works for you right now so be it You'll have to live with the $ids and $refs though
fromliberty
fromlibertyOP•12mo ago
oh i can just do:
ReferenceHandler.IgnoreCycles
ReferenceHandler.IgnoreCycles
` why not a great idea i want to show on my frontend
Angius
Angius•12mo ago
Could ignore the cycles, sure Do you really need to show everything? And nested so much, too? Right now you have a list of products, each product has colours, each of those colours has products, each of those products has colours... Why not just show the product, and the colour names?
fromliberty
fromlibertyOP•12mo ago
hmm
Angius
Angius•12mo ago
Why do you need to load all of the products in green, when the user just wants to see the dress?
fromliberty
fromlibertyOP•12mo ago
because in frontend people click the colour, and show that colour i think there was product mockup in frontend my products should look like this:
{
id: 8,
labels: "Best Selling",
category: "fashion",
img: img8,
hover_img: img2,
title: "Skater Dress",
price: 21,
description: `Nulla quis lorem ut libero malesuada feugiat. Donec sollicitudin molestie malesuada.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec rutrum congue leo eget malesuada.`,
rating: {
rate: 2.9,
count: 20
},
color: [
{
color: "green",
img: img9,
quantity: 1,
},
{
color: "red",
img: img8,
quantity: 1,
},
{
color: "blue",
img: img10,
quantity: 1,
},
]
},
{
id: 8,
labels: "Best Selling",
category: "fashion",
img: img8,
hover_img: img2,
title: "Skater Dress",
price: 21,
description: `Nulla quis lorem ut libero malesuada feugiat. Donec sollicitudin molestie malesuada.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec rutrum congue leo eget malesuada.`,
rating: {
rate: 2.9,
count: 20
},
color: [
{
color: "green",
img: img9,
quantity: 1,
},
{
color: "red",
img: img8,
quantity: 1,
},
{
color: "blue",
img: img10,
quantity: 1,
},
]
},
`
Angius
Angius•12mo ago
Yeah, the person clicks the colour That loads a new view, with that colour and items associated with it With a separate request Don't try to just load your entire database to the client
fromliberty
fromlibertyOP•12mo ago
hmmm so this is bad model ? :
public class Colour
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string? Img { get; set; }
public int Quantity { get; set; }

public int ProductId { get; set; }
public Product Product { get; set; }

}
public class Colour
{
[Key]
public int Id { get; set; }
public string Name { get; set; }
public string? Img { get; set; }
public int Quantity { get; set; }

public int ProductId { get; set; }
public Product Product { get; set; }

}
Angius
Angius•12mo ago
The user wants to see the dress. Cool, load the dress and related data. The model is good It's how you load the data that's causing the issues Load the product, load its' colours, stop Don't load all products associated with all the colours
fromliberty
fromlibertyOP•12mo ago
oh
Angius
Angius•12mo ago
var product = await _context.Products
.Where(p => p.Id == id)
.Select(p => new ProductDto {
Name = p.Name,
Description = p.Description,
Colours = p.Colours.Select(c => new ColourDto {
Id = c.Id,
Name = c.Name // we only load what we need to show the colour
}),
Labels = p.Labels.Select(l => new LabelDto {
Id = l.Id,
Name = l.Name // and only what we need for the label
}),
Price = p.Price,
})
.FirstOrDefaultAsync(); // we only load the requested product
var product = await _context.Products
.Where(p => p.Id == id)
.Select(p => new ProductDto {
Name = p.Name,
Description = p.Description,
Colours = p.Colours.Select(c => new ColourDto {
Id = c.Id,
Name = c.Name // we only load what we need to show the colour
}),
Labels = p.Labels.Select(l => new LabelDto {
Id = l.Id,
Name = l.Name // and only what we need for the label
}),
Price = p.Price,
})
.FirstOrDefaultAsync(); // we only load the requested product
fromliberty
fromlibertyOP•12mo ago
No description
fromliberty
fromlibertyOP•12mo ago
hmm also this is get all products method
Angius
Angius•12mo ago
Well, yeah, you have it called ProductId not Id
fromliberty
fromlibertyOP•12mo ago
this is for getproductbyid method right
Angius
Angius•12mo ago
var product = await _context.Products
.Select(p => new ProductDto {
Name = p.Name,
Description = p.Description,
Colours = p.Colours.Select(c => new ColourDto {
Id = c.Id,
Name = c.Name // we only load what we need to show the colour
}),
Labels = p.Labels.Select(l => new LabelDto {
Id = l.Id,
Name = l.Name // and only what we need for the label
}),
Price = p.Price,
})
.ToListAsync(); // we only load the requested product
var product = await _context.Products
.Select(p => new ProductDto {
Name = p.Name,
Description = p.Description,
Colours = p.Colours.Select(c => new ColourDto {
Id = c.Id,
Name = c.Name // we only load what we need to show the colour
}),
Labels = p.Labels.Select(l => new LabelDto {
Id = l.Id,
Name = l.Name // and only what we need for the label
}),
Price = p.Price,
})
.ToListAsync(); // we only load the requested product
Here, this will load all products Still, it's just sample code Adjust it accordingly (and you can ditch the automapper in this case, .Select() does the job)
fromliberty
fromlibertyOP•12mo ago
bruh, dto -> model problem again
No description
fromliberty
fromlibertyOP•12mo ago
😩 though we didnt include mapper maybe due to that it gave error ? 🤔
Angius
Angius•12mo ago
Your code says otherwise
No description
Angius
Angius•12mo ago
As I said, adjust the code accordingly If your Label has a list of names instead of a single name, then you'll need to change it For example
fromliberty
fromlibertyOP•12mo ago
it just says cannot convert, doesnt give why lol
Angius
Angius•12mo ago
Read the error You have IEnumerable<ModelDto> where ICollection<Colour> is expected
fromliberty
fromlibertyOP•12mo ago
so i need to say new Colour instead ? ohhh now i got it public ICollection<Colour> Colours { get; set; } productdto has this should be ColourDto probablyt
Angius
Angius•12mo ago
Yep
fromliberty
fromlibertyOP•12mo ago
error changed now
No description
fromliberty
fromlibertyOP•12mo ago
still error 🤔 ICollection - IEnumerable incompatibility lol
Angius
Angius•12mo ago
Use a List instead of ICollection maybe
fromliberty
fromlibertyOP•12mo ago
hmm is list ienumarable ?
fromliberty
fromlibertyOP•12mo ago
No description
fromliberty
fromlibertyOP•12mo ago
hmm it strictly wants that lol weird public IEnumerable<ColourDto> Colours { get; set; } would that break code ?
Angius
Angius•12mo ago
Add a .ToList() after the .Select() then
fromliberty
fromlibertyOP•12mo ago
ah
Angius
Angius•12mo ago
var product = await _context.Products
.Select(p => new ProductDto {
Name = p.Name,
Description = p.Description,
Colours = p.Colours.Select(c => new ColourDto {
Id = c.Id,
Name = c.Name // we only load what we need to show the colour
}).ToList(), // <--- here
Labels = p.Labels.Select(l => new LabelDto {
Id = l.Id,
Name = l.Name // and only what we need for the label
}).ToList(), // <--- here
Price = p.Price,
})
.ToListAsync(); // we only load the requested product
var product = await _context.Products
.Select(p => new ProductDto {
Name = p.Name,
Description = p.Description,
Colours = p.Colours.Select(c => new ColourDto {
Id = c.Id,
Name = c.Name // we only load what we need to show the colour
}).ToList(), // <--- here
Labels = p.Labels.Select(l => new LabelDto {
Id = l.Id,
Name = l.Name // and only what we need for the label
}).ToList(), // <--- here
Price = p.Price,
})
.ToListAsync(); // we only load the requested product
fromliberty
fromlibertyOP•12mo ago
but it cries in colour part though lol
Angius
Angius•12mo ago
Cries how?
fromliberty
fromlibertyOP•12mo ago
also what Ambiguous invocation: means btw
Angius
Angius•12mo ago
Means it doesn't know which overload of a given method it's supposed to call
fromliberty
fromlibertyOP•12mo ago
oh it gives that error for select
Angius
Angius•12mo ago
And it's ambiguous between shich methods?
fromliberty
fromlibertyOP•12mo ago
hard to read
No description
Angius
Angius•12mo ago
Uh, stick .AsQueryable() before the .Select()s?
fromliberty
fromlibertyOP•12mo ago
hmm now trying to load LabelProducts, is that good idea ? its a join table
Angius
Angius•12mo ago
var product = await _context.Products
.Select(p => new ProductDto {
Name = p.Name,
Description = p.Description,
Colours = p.Colours.AsQueryable().Select(c => new ColourDto {
Id = c.Id,
Name = c.Name // we only load what we need to show the colour
}).ToList(),
Labels = p.Labels.AsQueryable().Select(l => new LabelDto {
Id = l.Id,
Name = l.Name // and only what we need for the label
}).ToList(),
Price = p.Price,
})
.ToListAsync(); // we only load the requested product
var product = await _context.Products
.Select(p => new ProductDto {
Name = p.Name,
Description = p.Description,
Colours = p.Colours.AsQueryable().Select(c => new ColourDto {
Id = c.Id,
Name = c.Name // we only load what we need to show the colour
}).ToList(),
Labels = p.Labels.AsQueryable().Select(l => new LabelDto {
Id = l.Id,
Name = l.Name // and only what we need for the label
}).ToList(),
Price = p.Price,
})
.ToListAsync(); // we only load the requested product
fromliberty
fromlibertyOP•12mo ago
main select gives erorr not those _context.Products.Select one
Angius
Angius•12mo ago
Ah, well, if you have an explicit many-to-many set up you might need some other mapping inside of the .Select(). Like Id = l.Label.Id instead of Id = l.Id Ah, huh What is _context.Products? DbSet<Product> I'd assume?
fromliberty
fromlibertyOP•12mo ago
public DbSet<Product> Products { get; set; } yeah
Angius
Angius•12mo ago
Looks fine Show me your current query code
fromliberty
fromlibertyOP•12mo ago
No description
fromliberty
fromlibertyOP•12mo ago
to show errors, ss'ed instead code itself:
public async Task<IEnumerable<ProductDto>> GetProducts()
{
var product = await _db.Products
.Select(p => new ProductDto {
Name = p.Name,
Description = p.Description,
Colours = p.Colours.Select(c => new ColourDto {
Id = c.Id,
Name = c.Name, // we only load what we need to show the colour
Img = c.Img,
Quantity = c.Quantity
}).ToList(),
LabelProducts = p.LabelProducts.Select(l => new LabelProductDto {
LabelId = l.LabelId,
Label = l.Label // and only what we need for the label
}).ToList(),
Price = p.Price,
})
.ToListAsync(); // we only load the requested product
return _mapper.Map<List<ProductDto>>(productList);
}
public async Task<IEnumerable<ProductDto>> GetProducts()
{
var product = await _db.Products
.Select(p => new ProductDto {
Name = p.Name,
Description = p.Description,
Colours = p.Colours.Select(c => new ColourDto {
Id = c.Id,
Name = c.Name, // we only load what we need to show the colour
Img = c.Img,
Quantity = c.Quantity
}).ToList(),
LabelProducts = p.LabelProducts.Select(l => new LabelProductDto {
LabelId = l.LabelId,
Label = l.Label // and only what we need for the label
}).ToList(),
Price = p.Price,
})
.ToListAsync(); // we only load the requested product
return _mapper.Map<List<ProductDto>>(productList);
}
`
Angius
Angius•12mo ago
Weird, that looks good
fromliberty
fromlibertyOP•12mo ago
it has 4 errors lol
Angius
Angius•12mo ago
Try adding .AsQueryable() there
fromliberty
fromlibertyOP•12mo ago
weirdly
fromliberty
fromlibertyOP•12mo ago
No description
fromliberty
fromlibertyOP•12mo ago
similar error maybe its automapper error ?
fromliberty
fromlibertyOP•12mo ago
hmm also this error...
No description
fromliberty
fromlibertyOP•12mo ago
figured out, but still cant load label 🤔
"labelProducts": [
{
"labelProductId": 0,
"productId": 0,
"labelId": 1,
"product": null,
"label": null
}
],
"labelProducts": [
{
"labelProductId": 0,
"productId": 0,
"labelId": 1,
"product": null,
"label": null
}
],
`
fromliberty
fromlibertyOP•12mo ago
@ZZZZZZZZZZZZZZZZZZZZZZZZZ seems original problem is l.Label part
No description
fromliberty
fromlibertyOP•12mo ago
if i delete that, all problems gone then i cant fetch label confusing part is querying many-to-many relationships in linq
Want results from more Discord servers?
Add your server