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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:24:40+00:00 2026-05-14T00:24:40+00:00

I just started playing with Linq to entities in a windows forms application and

  • 0

I just started playing with Linq to entities in a windows forms application and am not understanding one behavior that looks so simple though.

If i type code below, i get ReadOnly records in my dataGridView

Dim x = From n in Table1 _
        Select n.FirstName, n.LastName, N.Department
DataGridView1.DataSource = x 

But if i type the following code, i get editable rows in my dataGridView

Dim x = From n in Table1 _
        Select n
DataGridView1.DataSource = x

So, basically if i specify the column names to select and databind to my DataGridView1, the rows are readonly but if i do not specify the column names and databind to the DataGridView, the rows are editable and i don’t understand why.

  • 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-14T00:24:40+00:00Added an answer on May 14, 2026 at 12:24 am

    There is an MSDN article about this.

    After a little searching and lots of editing my answer, it seems like the culprit must be anonymous types. The documentation indicates that the non-key fields of anonymous types should be read-write, but you might be invoking some kind of exception to this rule. I would debug in and check the exact type of x in both cases.

    There’s another possible hint in this blog entry by someone. “The LINQ query expressions will automatically use Key fields in any situation where a key is going to be generated (for example, Group By), […]” It might be that fields created by using the Select method are automatically Key properties.

    Another Stackoverflow answer hints at this – they match the type of some results from a Select method call by putting Key on the fields of the other type.

    Edit: And this article (thanks, Greg Stuntz) comes right out and says it. Geez. “You can simplify the anonymous type definition when writing a LINQ query by omitting the New With and the { }’s, but be aware this creates fully immutable types.”

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

Sidebar

Related Questions

Have just started playing with ASP.NET MVC and have stumbled over the following situation.
I've just started playing with Django and am loosely following the tutorial with my
I have just started playing with the ASP.Net MVC framework, and today I created
Just started getting a bunch of errors on our C# .Net app that seemed
I just started using the WPF WebBrowser that is included in Net 3.5 SP1.
Have just started using Google Chrome , and noticed in parts of our site,
I just started thinking about creating/customizing a web crawler today, and know very little
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I just started using GNU Emacs as my text editor and I am concerned
I just started to learn Ruby and as a .Net developer, I'm wondering if

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.