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 8467297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:36:07+00:00 2026-06-10T15:36:07+00:00

I am attempting to use the answer in post: How do you sort an

  • 0

I am attempting to use the answer in post: How do you sort an EntitySet<T> to expose an interface so that I can sort an EntitySet with a Binding list. I have created the class below and I get the following compiler error: “The type or namespace ‘P’ could not be found (are you missing a using directive or assembly reference?). Can someone tell me what the P means and which namespace I need to include to get the method below to compile? I am very new to delegates and lamba expressions.

Also, can someone confirm that if I create a BindingList from my EntitySet that any modifications I make to the BindingList will be made to the EntitySet?

Basically, I have an EntitySet that I need to sort and make changes to. Then, I will need to persist these changes using the original Entity that the BindingList came from.

public class EntitySetBindingWrapper<T> : BindingList<T>
{
    public EntitySetBindingWrapper(BindingList<T> root)
        : base(root)
    {
    }

            public void Sort<P>(Expression<Func<T, P>> expr, ListSortDirection direction)
    {
        if (expr == null)
            base.RemoveSortCore();

        MemberExpression propExpr = expr as MemberExpression;
        if (propExpr == null) throw new ArgumentException("You must provide a property", "expr");

        PropertyDescriptorCollection descriptorCol = TypeDescriptor.GetProperties(typeof(T));
        IEnumerable<PropertyDescriptor> descriptors = descriptorCol.Cast<PropertyDescriptor>();
        PropertyDescriptor descriptor = descriptors.First(pd => pd.Name == propExpr.Member.Name);

        base.ApplySortCore(descriptor, direction);
    }
}

I finally got the code above to compile but, now I am getting an error when I try to call the constructor:

The following code where currentPredefinedJob.fkItems is the EntitySet results in error: Cannot convert from System.ComponentModel.IBindingList to System.ComponentModel.BindingList

var bindingWrapper = new EntitySetBindingWrapper<PredefinedJobsItem>(currentPredefinedJob.fkItems.GetNewBindingList());

And, the following code results in error: Error 8 Using the generic type ‘MarineService.Tests.EntitySetBindingWrapper’ requires ‘1’ type arguments

var bindingWrapper = new EntitySetBindingWrapper(currentPredefinedJob.fkItems.GetNewBindingList());

Can someone tell me how I need to call this constructor and confirm how I would sort the resulting BindingList?

  • 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-10T15:36:08+00:00Added an answer on June 10, 2026 at 3:36 pm

    You need to specify the generic variable in either your class definition or method definition.

    P will be the type returned by your function expr

    public void Sort<P>(Expression<Func<T, P>> expr, ListSortDirection direction)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have noticed while monitoring/attempting to answer common jQuery questions, that there are certain
I am attempting to use the code found in the answer here: Directory.Move doesn't
In attempting to use std::select1st from <functional> in a VS2008 project I found that
I am attempting to create an application that will automatically answer calls when a
Attempting to use the data series from this example no longer passes the JSONLint
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng
When attempting to use HttpWebRequest to retrieve a page from my dev server, I
Im attempting to use a C++ extension for Python called PySndObj. and getting an
Im attempting to use websockets for a project. It needs to use the ipad,
I am attempting to use the data sources pluigin for rubymine 4.0.3 but I

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.