Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8523505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:25:41+00:00 2026-06-11T07:25:41+00:00

I’m trying to make use of James McCormack’s guide to using a custom IComparer

  • 0

I’m trying to make use of James McCormack’s guide to using a custom IComparer with Dynamic Linq. – see http://zootfroot.blogspot.co.uk/2009/10/dynamic-linq-orderby.html?showComment=1347276236930#c11348033278810583

I use a query to pull back an Enumerable of string values:

.Select("fieldname").Distinct()

Then try to use

.OrderBy(item=>item.GetReflectedPropertyValue("fieldname"),new myComparer()) 

GetReflectedPropertyValue is a helper method defined by James as

public static string GetReflectedPropertyValue(this object subject, string field)
{
object reflectedValue = subject.GetType().GetProperty(field).GetValue(subject, null);
return reflectedValue != null ? reflectedValue.ToString() : "";
}

But get the error “‘System.Collections.Generic.IEnumerable’ does not contain a definition for ‘OrderBy’ and the best extension method overload ‘System.Linq.Dynamic.DynamicQueryable.OrderBy(System.Linq.IQueryable, string, params object[])’ has some invalid arguments”

Any ideas? I’m new to this and just trying to get something working before I get the time to actually go through and learn it properly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:25:42+00:00Added an answer on June 11, 2026 at 7:25 am

    it’s hard to tell based only on what you’ve posted because the resolution of OrderBy will depend on the implementation of myConverter. But, Since GetReflectedPropertyValue returns string, myConverter must implement IConverter<String> to be used with OrderBy. If it doesn’t, and it implements something like IComparer<MyItem> then compiler is really looking for a method OrderBy(this IEnumerable<object>, Func<object,string>, IComparer<MyItem>) which doesn’t exist and spits out that error.

    If that isn’t clear, provide the details of myConverter and I can be more specific.

    If you’re using something that doesn’t implement IComparer<T>, then you can wrap the IComparer with something that implements IComparable<string> so that it is compatible with Orderby. For example:

    public class MyStringComparer : IComparer<String>
    {
        readonly IComparer comparer = new MyComparer();
        public int Compare(string x, string y)
        {
            return comparer.Compare(x, y);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.