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

  • Home
  • SEARCH
  • 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 1018257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:49:53+00:00 2026-05-16T10:49:53+00:00

I am not expert in ASP so i would be appreciated for the help.

  • 0

I am not expert in ASP so i would be appreciated for the help. Issue connected to Entity FW, ListView Control, its Datasource and type convertion.

I have the following LINQ query :

RoutesEntities routesModel = new RoutesEntities();
LocalesEntities localesModel = new LocalesEntities();
ObjectQuery routesQuery = (ObjectQuery) from routes in routesModel.Routes
                                        join locales in localesModel.Locales
                                        on routes.LocaleID equals locales.LocaleID
                                        where locales.IsActive == true
                                        select new {
                                             LocaleID = routes.LocaleID,
                                             RouteName = routes.RouteName
                                        };

AdminTopListView.DataSource = routesQuery;
AdminTopListView.DataBind(); // this line cause the error

If there is no JOIN for tables all is OK. In all other cases i get the error says that there are 2 contexts for only one LINQ statement.

The questions are :

  1. what types except ObjectQuery can be accepted by ListView datasource?
  2. how to convert Anonymous Type returned by LINQ to ObjectQuery?

Thanks in advance.

  • 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-16T10:49:54+00:00Added an answer on May 16, 2026 at 10:49 am

    It happens to be the case that the error you observed is due not to data-binding, but to LINQ. LINQ queries are lazily executed, meaning they do not actually retrieve data until absolutely necessary. This explains why you do not see symptoms until the .DataBind() call.

    A data binding statement to a list view can take many different kinds of data types. I usually bind an IList, array, or DataTable. Your LINQ query results will always apply if enumerable.

    If you combine your data contexts into one context, you can perform your join without error. If that option is not available, retrieve your collections first as a local list, and then create a LINQ-to-objects query.

    var routesQuery = from routes in routesModel.Routes.ToList()
                      join locales in localesModel.Locales.ToList()
                      on routes.LocaleID equals locales.LocaleID
                      // ...
    

    (Note: you can achieve better performance if you pre-filter the result set prior to loading the data .ToList()).

    I strongly prefer the solution of combining data contexts.

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

Sidebar

Related Questions

This is related to this question . I'm not an expert on Linux device
I not a DB expert, so am looking for advice for a web-based system
$(document).ready(function() { $(span.link).mouseover(function(e){ $(this.children).css(display,inline); }); }); I'm not a javascript expert, but I've cobbled
I'm not considering this - I'm comfortable with C# and VB, but an expert
Until now, I have not create any massive applications using ASP.Net. However, I am
so I'm very very far from an expert on MVC or ASP.NET. I just
I have exceptions created for every condition that my application does not expect. UserNameNotValidException
getopt() is not behaving as I expect for short options. eg: Invoking the below
Sorry, I'm not terribly experienced with Ant. I like the eclipse Export ant buildfile
Not very technical, but... I have to implement a bad words filter in a

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.