There is no argument given that corresponds to the required formal parameter - .NET Error

后端 未结 5 1100
迷失自我
迷失自我 2020-11-29 11:26

I have been re-factoring one of my old MSSQL Connection helper library and I got the following error:

Severity Code Description Project File Li

5条回答
  •  暖寄归人
    2020-11-29 11:48

    I received this same error in the following Linq statement regarding DailyReport. The problem was that DailyReport had no default constructor. Apparently, it instantiates the object before populating the properties.

    var sums = reports
        .GroupBy(r => r.CountryRegion)
        .Select(cr => new DailyReport
        {
            CountryRegion = cr.Key,
            ProvinceState = "All",
            RecordDate = cr.First().RecordDate,
            Confirmed = cr.Sum(c => c.Confirmed),
            Recovered = cr.Sum(c => c.Recovered),
            Deaths = cr.Sum(c => c.Deaths)
        });
    

提交回复
热议问题