How Can I remove duplicates in Order Placed column and only leave one row for each date?
I tried a few expressions but I have only first 4 orders still with the same date. I also tried GroupBy, OrderBy.
public IEnumerable<Order> GetOrder(string userId)
{
var order = _appDbContext.Orders.Include(x => x.OrderDetails)
.Include(x => x.Game)
.Where(x => x.OrderDetails.UserId == userId);
return order;
}
View Code:
@model IEnumerable<Order>
<h2>Your orders</h2>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th class="text-center">Order Number:</th>
<th class="text-center">Order Placed:</th>
<th class="text-center">Total:</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td class="text-center">
<a asp-controller="Order" asp-action="OrderDetails"
asp-route-orderPlaced="@item.OrderDetails.OrderPlaced" class="btn btn-primary">@item.OrderId</a>
</td>
<td class="text-center">@item.OrderDetails.OrderPlaced</td>
<td class="text-center">@(item.Price * item.Amount)</td>
</tr>
}
</tbody>
</table>