I have this query
List<int> AuctionIds =
(from a in _auctionContext.Auctions
where a.AuctionEventId == auction.AuctionEventId
select new { a.Id }).ToList();
But I receive a compile error
Cannot implicitly convert type 'System.Collections.Generic.List<AnonymousType#1>' to 'System.Collections.Generic.List<int>'
What type should AuctionIds be?
EDIT
The AuctionIds field is in fact in another class (a model class) so I can’t just use var. I can’t believe Jon Skeet hasn’t answered this.
You are adding an anonymous object to a
List<int>..If you were to do it the way you had it.. I would use the
varkeyword..Reason is I don’t know what type an anonymous object is.. but the compiler should be able to handle it.
EDIT:
Eh, about creating a
AuctionIDModelclass?