No generic method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic

12 posts, 0 answers
  1. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 03 Apr 2012 Link to this post

    Hi,
          i am using telerik silverlight chart.i got exception "No generic method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic" when tried to bind list to chart.
    When I use very small data it works fine. But for large number of records I get following error.

     RadChart1.ItemsSource = lst1;

    i also tried with changes suggested in the forums:
    ItemMapping mapping = new ItemMapping("Sales", DataPointMember.YValue, ChartAggregateFunction.Sum);
    mapping.FieldType = typeof(double)
    but with no luck.
    and i also noticed one thing that exception is occurring when result set is reaches more than 200

    Thanks.

  2. Manoj
    Manoj avatar
    2 posts
    Member since:
    Mar 2012

    Posted 04 Apr 2012 Link to this post

    I am also facing same problem.
  3. DevCraft banner
  4. Manoj
    Manoj avatar
    2 posts
    Member since:
    Mar 2012

    Posted 05 Apr 2012 Link to this post

    Any Update? I don't want to create duplicate ticket for this.
  5. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 06 Apr 2012 Link to this post

    Hello Rahul,

    I will need more information in order to be able to help you. Are you using any group settings? Do you have any other item mappings?

    200 is the default sampling threshold. Here you can read about sampling. So I guess that the problem will disappear when you disable sampling (by setting the threshold to zero). But I am not sure if this is the right way to go. You can send us some code that reproduces this, with which I can create a new project here so I can test it and try to find where the problem is.

    Manoj, even though you are getting a similar error it does not mean your problem is the same. You can either follow this thread or you can open a new support ticket and attach a small project that reproduces this so we can investigate your case, too. 

    All the best,
    Petar Marchev
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  6. Pat
    Pat avatar
    4 posts
    Member since:
    Sep 2011

    Posted 24 Oct 2012 Link to this post

    I seem to be getting this error when trying to chart data with DateTime as x-axis. In particular when x-axis data points are not unique. Wile trying to debug this it also tells me the Average function is not defined for collections of DateTime.
  7. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 25 Oct 2012 Link to this post

    Pat, we will need more information in order to help you. I have attached a simple app that demonstrates a bar chart which uses DateTime along its x-axis and takes advantage of the Sampling feature. I will ask of you that you open a new thread in which you explain your set up in more details and if possible - attach a modified version of the attached example that reproduces this exception.

    Greetings,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Mark
    Mark avatar
    12 posts
    Member since:
    Nov 2011

    Posted 15 Jan 2013 Link to this post

    I found that I have same problem when I try get values from dictionary. I cannot reproduce this error if I have same mapping/path in XAML

    string xPropertyName = "ReadTime";
    string yPropertyName = string.Format("Parameters[{0}].Value", item.Id /*int key value*/);
    //yPropertyName = "Parameters.TestValue"; //this path does not raise exception
     
    var seriesMapping = new SeriesMapping();
    seriesMapping.LegendLabel = item.Name;
    seriesMapping.ItemsSource = item.ParameterValueSets;
    seriesMapping.SeriesDefinition = lineSeriesDefinition;
    seriesMapping.ItemMappings.Add(new ItemMapping() { FieldName = xPropertyName, DataPointMember = DataPointMember.XValue });
    seriesMapping.ItemMappings.Add(new ItemMapping() { FieldName = yPropertyName, DataPointMember = DataPointMember.YValue });
     
    radChart.SeriesMappings.Add(seriesMapping);

  9. Mark
    Mark avatar
    12 posts
    Member since:
    Nov 2011

    Posted 17 Jan 2013 Link to this post

    I was wrong in my previous message. Problem is here property Parameters[0].Value return type is Syste.Object and not double/int/float/byte. So class ChartSamplingFunctions does not contain method like 

    public static object MemberFirst<TSource>(IEnumerable<TSource> source, Func<TSource, System.Object> selector)

    and method below just crushes with weird message.

    public override System.Linq.Expressions.Expression CreateAggregateExpression(System.Linq.Expressions.Expression enumerableExpression)
    {
        var builder = this.binding.CreateExpressionBuilder(enumerableExpression, this);
        return builder.CreateAggregateExpression();
    }

  10. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 18 Jan 2013 Link to this post

    Hello Mark,

    I apologize for not understanding you fully. Have you managed to resolve the issues you are experiencing or do you need assistance? You can open a new thread (so that we don't jam this thread) in which you can give us more details for your current app and if possible attach a small project that reproduces the issue, so that we can test and look for solutions. 

    Greetings,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  11. arun
    arun avatar
    2 posts
    Member since:
    Nov 2016

    Posted 04 Nov in reply to Manoj Link to this post

    I'm also facing same issue, when X-Axis has more than 200 data point or items; it is working fine with less than 200 data items on x-axis.
  12. arun
    arun avatar
    2 posts
    Member since:
    Nov 2016

    Posted 04 Nov in reply to Rahul Khinvasara Link to this post

    Hi,

    I'm getting below error when x-axis data item has 200 data point or items.  -

    An unhandled exception of type 'System.InvalidOperationException' occurred in WindowsBase.dll

    Additional information: No generic method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.

  13. Dinko
    Admin
    Dinko avatar
    202 posts

    Posted 08 Nov Link to this post

    Hello arun,

    We weren't able to reproduce this exception when the RadChartView is populated with 200 items. That is why we would ask you to send us sample project from your application reproducing this exception. This way we can further investigate it directly on our side.

    Regards,
    Dinko
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top
DevCraft banner