The ToDictionary() method call in this LINQ statement needs arguments. As it currently stands, the ToDictionary portion is a red squiggly, for lack of a better technical term. Error: No overload takes 0 arguments. Yeah, I know that.
I cannot add lambdas to the ToDictionary method call because Intellisense is overriding my lambda with its suggestion. In other words, if I type in "x ", it replaces it with XmlReader. Argh.
I've tried it with and without AsEnumerable. I borrowed most of this code from a StackOverflow post, but I added the dictionary portion.
Am I missing parentheses somewhere or something? Halllllp!
var props = (from p in _type.GetProperties()
let attr = p.GetCustomAttribute<ExcelExportAttribute>()
where attr != null && attr.ReportId.ToString() == reportID
select new {Prop = p, Att = attr })
.AsEnumerable()
.ToDictionary<PropertyInfo, ExcelExportAttribute>();
Error in VS
Severity Code Description Project File Line Suppression State Error CS1929 'IEnumerable<>' does not contain a definition for 'ToDictionary' and the best extension method overload 'Enumerable.ToDictionary(IEnumerable, Func, IEqualityComparer)' requires a receiver of type 'IEnumerable' WFG.UtilityLib.Excel C:\Users\kbessel\source\repos\WFG.UtilityLib.Excel\WFG.UtilityLib.Excel\ExcelExport.cs 142 Active
.ToDictionary(item => item.Prop, item => item.Att);
: you should provide key and value - Dmitry BychenkoAsEnumerable
. - juharrusing System.Linq;
sinceToDictionary()
is an extension method. - Dmitry Bychenko