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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:12:06+00:00 2026-06-14T18:12:06+00:00

I am just getting started with RavenDB and have run into a weird scenario.

  • 0

I am just getting started with RavenDB and have run into a weird scenario.

When I run the following query, the model gets populated just fine. Everything works great.

var contacts = Session.Query<Contact>()
                      .Where(c => c.UserId == this.userId)
                      .ToList();

var model = contacts.Select(c => new SelectListItem() { 
                                     Text = c.FullName, 
                                     Value = c.Id }).ToList();

However, that isn’t the code I started with. I started with the code below which populates the Text property from the contact FullName. For some random reason, it doesn’t populate the Value property from the contact id.

 var model = (from c in Session.Query<Contact>()
              where c.UserId == this.userId
              select new SelectListItem() { 
                         Text = c.FullName, 
                         Value = c.Id }).ToList();

I am not sure if this is a bug or if I am just missing something simple. Ideas?

** UPDATE **

It doesn’t like this syntax either. I must be missing something really basic here.

 var model = Session.Query<Contact>()
                    .Where(c => c.UserId == this.userId)
                    .Select(c => new SelectListItem() { Text = c.FullName, Value = c.Id })
                    .ToList();
  • 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-14T18:12:07+00:00Added an answer on June 14, 2026 at 6:12 pm

    The difference is that in the first case, you’ve got a ToList() call before the projection. So the only thing that the LINQ provider needs to worry about is the Where call. It will fetch all of the data for each Contact, and then the projection occurs in LINQ to Objects instead.

    In your second code, the Select call needs to be handled by the LINQ provider as well – and presumably it’s not doing the right thing.

    So yes, this sounds like a bug in the RavenDB LINQ provider, in the Select handling.

    Note that another way of forcing the rest of the query to execute in LINQ to Objects is to use AsEnumerable() – so this should work:

    var model = Session.Query<Contact>()
                       .Where(c => c.UserId == this.userId)
                       .AsEnumerable()
                       .Select(c => new SelectListItem { 
                                      Text = c.FullName, 
                                      Value = c.Id })
                       .ToList();
    

    (I’ve converted new SelectListItem() to new SelectListItem in the object initializer expression too, but that’s really a no-op.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am just getting started couchdb and have been looking into writing couch apps.
Just getting started on iPhone dev today and have run through Apple's HelloWorld tutorial:
Just getting started with Powershell and have a quick question. Trying to run this
Just getting started on NVelocity (v1.1.1) and it seems to be working just fine.
I'm just getting started with Python/Pandas and put together the following code to plot
I'm just getting started with Visual Studio (2010 Beta) and have some basic questions
I am just getting started with HTML/JavaScript, and I have a simple question. I
First off I'm just getting started with RavenDB so please be patient as I
Using JOliver EventStore 3.0, and just getting started with simple samples. I have a
I'm just getting started with knockout.js. I have a foreach binding like this, which

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.