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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:20:27+00:00 2026-05-16T02:20:27+00:00

I have a simple winforms application that I am connecting to my database with

  • 0

I have a simple winforms application that I am connecting to my database with linq-to-sql.

I have generated the classes directly from the database, and I have a DataAccess class that wraps my datacontext and can give me whatever I need.

I have a view that uses an object datasource to populate a DataGridView and a set of related text fields, etc.. for my entity (lets call it EmployeeView)

The view loads all of the existing rows, and as I click through the grid, the fields update appropriately.

If I change fields, the changes will persist through record changes, but I am not sure how to save changes through my data access layer. How can I detect which records are dirty and need to be saved? How do I then save them? What is the best way to add new records? Delete records?

I can find a lot of resources online, but none with the kind of examples I need. Can anyone help me out with some of the basic patterns, or point me to a good place?

  • 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-16T02:20:28+00:00Added an answer on May 16, 2026 at 2:20 am

    The most basic way to use LINQ-to-SQL classes, I believe, is to instantiate a list of them (let’s use Employee, for example) to contain the Employees you wish to (potentially) edit. When the properties of those Employee objects are changed, the objects are automatically “dirtied”, and a call to DataContext.SubmitChanges() will persist them.

    List<Employee> employees = (from e in dataContext.Employees where e.Salary > 50000 select e).toList();
    
    foreach(var employee in employees)
    {
      employee.CanAffordToyotaPrius = true;
    }
    
    dataContext.SubmitChanges();
    

    If you’re wrapping the DataContext and only altering the properties of the wrapper object with the DataGridView, you’ll need some way to bubble those changes down into the underlying LINQ-to-SQL objects you used when you selected the data. For example, you could use the setter on your wrapper’s properties to also set the underlying LtS object’s properties.

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

Sidebar

Related Questions

I have developed a simple C# Winforms application that loads MS-Word 2007 documents via
I have simple WinForms application where modifying Windows Registry. The problem is that in
I have a server application (singleton, simple .NET console application) that talks to a
If I wanted to have my data in SQL Server, but wanted to use
I have a simple web service to allow applications to query my CMDB. The
I realize that the answer to this question is likely quite obvious (if somewhat
I am starting one POS (Point of sale) project. Targeting system is going to
This is my first post to stackoverflow, so bear with me. :) I am
I am trying to upload files to a web server using System.Net.WebClient.UploadFile but I

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.