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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:06:35+00:00 2026-05-27T06:06:35+00:00

Iam have run into a little problem with a partial projection. I have an

  • 0

Iam have run into a little problem with a partial projection.

I have an method on our listboxes so that we can easily load entities into them, however loading full entities is of course not an option.
Meaning i have to do some projection, i have done this here where you can choose which Property to have as the DisplayValue.

Using the code looks like this:

dropCompany.LoadEntityList(Customer.Company, x => x.CompanyName, x => x.IsCompany);

Part of the implementation looks like this:

public void LoadEntityList<T>(T selectedEntity,
                              System.Linq.Expressions.Expression<Func<T, string>> selector,
                              System.Linq.Expressions.Expression<Func<T,bool>> where = null)
    where T : FlexyBook.Infrastructure.Entity
{
    var wCollection = new ObjectWrapperCollection<object>();
    IQueryable<T> query = FlexyBook.Repository.DomainService<T>.GetDomainService().GetAll();
    if (where != null)
        query = query.Where(where);
    foreach (var item in query.Select(x =>
        new ObjectWrapper<object>()
        {
            Value = x.ID,
            Text = selector.Compile()(x)
        })
        .ToList().OrderBy(x => x.Text))
    {
        wCollection.List.Add(item);
    }
}

The problem is that this results in the full entity being loaded from the database and then projected.
The issue is also very obvious it is this line “selector.Compile()(x)”.

My problem is i have no idea how to allow this partial select to carry on into NHibernate as a projection.
I obviously need the ID selector for identification of the entities and i dont want to change the way the method is called.

Is there anyway to solve this ?

  • 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-05-27T06:06:36+00:00Added an answer on May 27, 2026 at 6:06 am

    One way do to perform the partial select would be to change your selector expression to be of type:

    System.Linq.Expressions.Expression<Func<T, ObjectWrapper<object>>>
    

    Then you would call it like:

    dropCompany.LoadEntityList(Customer.Company, x => new ObjectWrapper<object>() { Value = x.ID, Text = x.CompanyName, x => x.IsCompany);
    

    The implementation:

    public void LoadEntityList<T>(T selectedEntity, System.Linq.Expressions.Expression<Func<T, ObjectWrapper<object>>> selector,System.Linq.Expressions.Expression<Func<T,bool>> where = null) where T : FlexyBook.Infrastructure.Entity
    {
        var wCollection = new ObjectWrapperCollection<object>();
        IQueryable<T> query = FlexyBook.Repository.DomainService<T>.GetDomainService().GetAll();
        if (where != null)
            query = query.Where(where);
        foreach (var item in query.Select(selector).ToList().OrderBy(x => x.Text))
        {
            wCollection.List.Add(item);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am relatively new to WPF and I have run into a little problem.
I have run into a strange problem, i am creating a lot of dynamically
I am developing an xbap application and have run into a problem with users
I am implementing exception handling for our BizTalk services, and have run into a
I am try the Google Maps API and run into a little problem. Look
I am just working on a simple little layout and I have run into
I am working on a web application and I have run into the following
I am writing unit tests for some of my code and have run into
I am creating a small Yahtzee game and i have run into some regex
I am trying to make my own Jabber bot but i have run into

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.