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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:47:38+00:00 2026-06-11T20:47:38+00:00

I am querying a set of Entity Framework objects and projecting them through a

  • 0

I am querying a set of Entity Framework objects and projecting them through a WCF RIA service into lightswitch.

In my query I perform a join between a couple of tables, one of which are details for a summary table. I want to determine which detail item is the ‘first’ item in the list and compare that to the current item in my projection during enumeration. The reason being in the projection I want to change which of my available properties sets this specific projection’s property.

This is the query so reduced

var result = (from dataItem in (from x in Context.xs
              join y in Context.ys
              on x.property = y.property
              select new {x, y})
              .Select( (model, index) =>
                          new ObjectType 
                              { 
                                  Id = index,
                                  OneOfTwo = model.x.property,
                                  (
                                       from y in Context.ys 
                                       where y.SomeProperty == model.Property
                                       select y)
                                       .OrderBy(list=>list.Id)
                                       .FirstOrDefault()
                                       .ComparedProperty ==model.ComparedProperty
                                   ) 
                                   ? model.AnotherProperty
                                   : model.YetAnotherProerty
                              }
               );

How can I evaluate that inner query without running into DataReader errors because I’m trying to use the Context while it is being read?

Update:
I did some research and realize that this is not a problem with linq to sql but it is a problem with linq to entities. Essentially that operation is the equivalent of using a parameterized query which isn’t supported. What are the workarounds in this situation?

  • 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-11T20:47:39+00:00Added an answer on June 11, 2026 at 8:47 pm

    The solution was to project the data to a List collection that I needed to data transfer objects and utilize linq to objects. I then exposed my collections through a WCFRIA service back to lightswitch.

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

Sidebar

Related Questions

I have a WCF Data Service that exposes an Entity Framework database context and
I am querying a database for results and trying to convert them into JSON
Here are two cases I've run into recently: Querying the set of tables for
I've set up mvc-mini-profiler against my Entity Framework-powered MVC 3 site. Everything is duly
I have been looking into using the Entity Framework in my C# game server
When using traditional Entity Framework and querying with ESQL, you can use OFTYPE with
I have an entity set (lets call it Clients) that I am querying using
Trying to use Linq with some Entity objects to do a crafty query here.
Querying a Nested Set Model table , here's the SQL... how can this be
I am querying the Microsoft Office SharePoint Server Search Service to write some results

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.