Convert Linq Query Result to Dictionary
Try using the ToDictionary
method like so:
var dict = TableObj.Select( t => new { t.Key, t.TimeStamp } )
.ToDictionary( t => t.Key, t => t.TimeStamp );
Looking at your example, I think this is what you want:
var dict = TableObj.ToDictionary(t => t.Key, t=> t.TimeStamp);
Try the following
Dictionary<int, DateTime> existingItems =
(from ObjType ot in TableObj).ToDictionary(x => x.Key);
Or the fully fledged type inferenced version
var existingItems = TableObj.ToDictionary(x => x.Key);