Reputation: 1119
I have two tables which used to generate two entities. For example: issue and owner (one owner can own multiple issues, not vice versa). Now I want load these into memory at run time for performance reason (to look up owner give an issue). So I think I can have dictionary Dictionary(IssueEntityComparer). How do I build up this dictionary in C#?
Upvotes: 2
Views: 1006
Reputation: 6312
Try this:
var map = db.Issues
.Select (i => new { Key = i.IssueId, Value = i.OwnerId })
.ToDictionary (i => i.Key, i => i.Value);
Upvotes: 2