Reputation: 36743
Here's the code:
var userA = auction.UserAuctionLances.OrderByDescending(d => d.DateTimeOfLance)
.Select(u => u.User).FirstOrDefault();
Here's a view of the data in my database, specifically the UserAuctionLance table.
And here's a view of the tables relationships. Remember I'm using Entity Framework:
Basically, I want to get the .Login property of the last User
who bid in the auction. However, my Linq query is fetching the very first user in the User table.
What am I doing wrong?
Upvotes: 0
Views: 71
Reputation: 70369
use
var userA = auction.UserAuctionLances.OrderByDescending(d => d.DateTimeOfLance).FirstOrDefault().User;
Upvotes: 3