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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:15:30+00:00 2026-06-18T02:15:30+00:00

I have Data = new ObservableCollection<DATA>(dataContext.DATA); dataContext is my Entities. DATA is SQL Server

  • 0

I have Data = new ObservableCollection<DATA>(dataContext.DATA);

dataContext is my Entities. DATA is SQL Server table.

Now I run Import method, which fills DATA table on SQL Server:

    public static void Import(DataTable table)
    {
        var dataContext = DataContext.Instance.Entities;

        foreach (DataRow row in table.Rows)
        {
            .......

            var dataRow = new DATA
            {
               .........
            };

            dataContext.AddToDATA(dataRow);
        }
        dataContext.SaveChanges();
    }

But my ObservableCollection Data is still empty. How do I update it?

  • 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-18T02:15:32+00:00Added an answer on June 18, 2026 at 2:15 am

    ObservableCollection<T> Constructor (IEnumerable<T>):

    Initializes a new instance of the ObservableCollection class that
    contains elements copied from the specified collection.

    The keyword here is that it copies the element from the collection. After that it does not retain any synchronization with the enumeration that you passed in. Your code is updating the dataContext object, not your Data object (The ObservableCollection). You will either have to build out your own synchronized version of ObservableCollection or create methods to keep them in sync.

    If you aren’t concerned with keeping the dataContext object synchronized and only wanted to use it in the one-time load, then you have to have all the appropriate objects in that enumeration before using it in the constructor of your ObservableCollection.

    My guess is you do something similar to the following:

    Data = new ObservableCollection<DATA>(dataContext.DATA)
    
    // Afterwards...
    Import(foobar);
    

    It should be:

    Import(foobar);
    
    // Afterwards...
    Data = new ObservableCollection<DATA>(dataContext.DATA)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table into which new data is frequently inserted. I need to
I have data table containing one column as FilePath. FilePath D:\New folder\link.txt D:\New folder\SharepointMigration(Work
I have a jQuery script that polls my server for new data, but it
im new to regular expressions in php. I have some data in which some
I have created a data table which contains 4 columns, 3 are strings and
I have data like the following: var data = [{ id: 1, date: new
I have a web scraping script that gets new data once every minute, but
I have this code: ... request data = new request(); data.username = formNick; xml
Scenario: old legacy code in rpg have to consume data from a new web
When saving a new entity something strange happens... I have a data grid with

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.