Ross
Ross

Reputation: 362

Model.OrderBy failing in partial view

I've got an MVC 3 app that uses a couple of partial views but it is failing on this line

 title = "by " + Model.OrderBy.Field;

As far as I can tell I've got the right method in the model

        public OrderByInfo OrderBy
    {
        get { return _orderBy; }
    }

but it tells me OrderBy is a method, which is not valid in the given context.

Any ideas?

Upvotes: 1

Views: 490

Answers (2)

Ross
Ross

Reputation: 362

It ended up being something to do with the project being opened up in VS2010. I'm running it with VS2008 and it's fine. I'll have to go through the upgrade process at some point.

Upvotes: 1

marcind
marcind

Reputation: 53183

Is your model an IEnumerable. My guess is there might be some conflict with the the OrderBy() LINQ extension method. Is your OrderBy property defined on a class that is a collection of models or on a particular model?

Upvotes: 1

Related Questions