I have a list of type ProductDetailDTO.
List<ProductDetailDTO> productDTOs;
public class ProductDetailDTO
{
public int ProductId { get; set; }
public string Name { get; set; }
public string Category { get; set; }
public byte[] Image { get; set; }
public string Description { get; set; }
public string Brand { get; set; }
public string GUID { get; set; }
public string VariantName { get; set; }
public string VariantValue { get; set; }
public decimal Price { get; set; }
}
I have used linq to bind the data to the list.
var productDetails = (from product in ekartEntities.Products
join productImage in ekartEntities.ProductImages on product.ProductId equals productImage.ProductId
join category in ekartEntities.ProductCategories on product.Category equals category.CategoryId
join mapping in ekartEntities.ProductVariantMappings on product.ProductId equals mapping.ProductId
join variant in ekartEntities.ProductVariants on mapping.ProductVariantId equals variant.ProductVariantId
join inventory in ekartEntities.Inventories on mapping.GUID equals inventory.Guid
where product.ProductId == productDetailDTO.ProductId
select new ProductDetailDTO()
{
ProductId = product.ProductId,
Name = product.Name,
Category = category.Name,
Description = product.Description,
Brand = product.Brand,
Image = productImage.Image,
GUID = mapping.GUID.ToString(),
VariantName = variant.Name,
VariantValue = mapping.Value,
Price = inventory.Price
}).ToList();
Now, I want to display all the variants (VariantName and VariantValue) with the same GUIDs together. How can I achieve that?