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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:37:05+00:00 2026-05-14T06:37:05+00:00

I am writing a small application that does a lot of feed processing. I

  • 0

I am writing a small application that does a lot of feed processing. I want to use LINQ EF for this as speed is not an issue, it is a single user app and, in the end, will only be used once a month.

My questions revolves around the best way to do bulk inserts using LINQ EF.

After parsing the incoming data stream I end up with a List of values. Since the end user may end up trying to import some duplicate data I would like to “clean” the data during insert rather than reading all the records, doing a for loop, rejecting records, then finally importing the remainder.

This is what I am currently doing:

DateTime minDate = dataTransferObject.Min(c => c.DoorOpen);
DateTime maxDate = dataTransferObject.Max(c => c.DoorOpen);

using (LabUseEntities myEntities = new LabUseEntities())
{
    var recCheck = myEntities.ImportDoorAccess.Where(a => a.DoorOpen >= minDate && a.DoorOpen <= maxDate).ToList();
    if (recCheck.Count > 0)
    {
        foreach (ImportDoorAccess ida in recCheck)
        {
            DoorAudit da = dataTransferObject.Where(a => a.DoorOpen == ida.DoorOpen && a.CardNumber == ida.CardNumber).First();
            if (da != null)
                da.DoInsert = false;
        }
    }

    ImportDoorAccess newIDA;
    foreach (DoorAudit newDoorAudit in dataTransferObject)
    {
        if (newDoorAudit.DoInsert)
        {
            newIDA = new ImportDoorAccess
            {
                CardNumber = newDoorAudit.CardNumber,
                Door = newDoorAudit.Door,
                DoorOpen = newDoorAudit.DoorOpen,
                Imported = newDoorAudit.Imported,
                RawData = newDoorAudit.RawData,
                UserName = newDoorAudit.UserName
            };
            myEntities.AddToImportDoorAccess(newIDA);
        }
    }
    myEntities.SaveChanges();
}

I am also getting this error:

System.Data.UpdateException was unhandled
Message=”Unable to update the EntitySet ‘ImportDoorAccess’ because it has a DefiningQuery and no element exists in the element to support the current operation.”
Source=”System.Data.SqlServerCe.Entity”

What am I doing wrong?

Any pointers are welcome.

  • 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-14T06:37:06+00:00Added an answer on May 14, 2026 at 6:37 am

    You can do multiple inserts this way.

    I’ve seen the exception you’re getting in cases where the model (EDMX) is not set up correctly. You either don’t have a primary key (EntityKey in EF terms) on that table, or the designer has tried to guess what the EntityKey should be. In the latter case, you’ll see two or more properties in the EDM Designer with keys next to them.

    Make sure the ImportDoorAccess table has a single primary key and refresh the model.

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

Sidebar

Related Questions

I'm writing a small application in VB.NET and I would like some of the
I've been writing writing a small pygtk application using glade to put together the
I'm writing a small agent in java that will play a game against other
I'm writing a small GUI app that contains some editor functionality, and something that
I am writing a small application using Rails 3. In one part of it
I'm writing a very small application for my organization. As nobody seems to know
I'm writng a small application in PHP + MySQL and have come to the
I am currently writing a small calendar in ASP.Net C#. Currently to produce the
I'm writing a small tool in C# which will need to send and receive
I'm writing a small web server in Python, using BaseHTTPServer and a custom subclass

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.