Orchard.ContentManagement.IContentQuery<XX.Commerce.Models.ProductPart> does not contain a definition for 'OrderByDescending'

Topics: Customizing Orchard, Writing modules
Dec 13, 2012 at 9:21 AM
Edited Dec 13, 2012 at 2:32 PM

Hi everyone,

I am attempting to create a commerce module for Orchard. Actually, this is a fork of Bertrand's Nwazet. Don't worry, Bertrand, you'll get full credit for it. :-) I'm having an issue with the core framework.

So far I have used codegen to create a new module. Then I copied all the files from the downloaded copy of Nwazet into my module project. I have changed all references from Nwazet to XX (my clients name). I believe I have been pretty thorough. So at this point I should be able to simply compile and all would work fine. But instead I'm getting 2 errors in the ProductAdminController:

"'Orchard.ContentManagement.IContentQuery<XX.Commerce.Models.ProductPart>' does not contain a definition for 'OrderByDescending' and the best extension method overload 'System.Linq.ParallelEnumerable.OrderByDescending<TSource,TKey>(System.Linq.ParallelQuery<TSource>, System.Func<TSource,TKey>)' has some invalid arguments"

and

"Instance argument: cannot convert from 'Orchard.ContentManagement.IContentQuery<XX.Commerce.Models.ProductPart>' to 'System.Linq.ParallelQuery<Orchard.Core.Common.Models.CommonPartRecord>'"

The offending code is

var query = _contentManager.Query<ProductPart>(VersionOptions.Latest);

            switch (model.Options.OrderBy) {
                case ContentsOrder.Modified:
                    //query = query.OrderByDescending<ContentPartRecord, int>(ci => ci.ContentItemRecord.Versions.Single(civr => civr.Latest).Id);
                    query = query.OrderByDescending<CommonPartRecord, DateTime?>(cr => cr.ModifiedUtc);
...
            }

Query is of type Orchard.ContentManagement.IContentQuery. In ContentExtensions.cs there is a

public static IContentQuery<TPart> Query<TPart>(this IContentManager manager, VersionOptions options) where TPart : ContentPart {
            return manager.Query().ForPart<TPart>().ForVersion(options);
        }

and in IContentQuery.cs there is a

public interface IContentQuery<TPart> : IContentQuery where TPart : IContent {
        .
        .
        .
    IContentQuery<TPart, TRecord> OrderByDescending<TRecord>(Expression<Func<TRecord, object>> keySelector) where TRecord : ContentPartRecord;
}
 

 

This all works fine if you download Nwazet. But somehow this isn't working in my project. Is a problem immediately obvious to anyone? Hopefully I've explained this well enough.

Thanks in advance!