You add an anonymous object to the List<int> . If you did it the way you did it. I would use the var keyword.
var AuctionIds = (from a in _auctionContext.Auctions where a.AuctionEventId == auction.AuctionEventId select new{Id = a.Id}).ToList();
The reason is because I donβt know what type of anonymous object is ... but the compiler must be able to handle it.
EDIT:
Eh, about creating an AuctionIDModel class?
public class AuctionIDModel { int Id{get;set;} } List<AuctionIDModel> AuctionIds = (from a in _auctionContext.Auctions where a.AuctionEventId == auction.AuctionEventId select new AuctionIDModel{Id = a.Id}).ToList();
source share