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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:15:57+00:00 2026-06-16T15:15:57+00:00

I am new to EF. I created entity models from database. I have tables

  • 0

I am new to EF. I created entity models from database.

I have tables CurrencyMaster([FromCurrency],[ToCurrency],[ActiveStatus]) and CurrencyConversion([ID],[FromCurrency],[ToCurrency],[Date],[CurrencyFactor])

I am looping for the CurrencyMaster records and accordingly DownloadCurrencyRates will get me the List<CurrencyRate> objects.
I just want to add these objects to entity database.

I tried something like this

public DownloadStatus DownloadUpdateCurrency(DateTime toDate, DateTime fromDate)
{
    CurrencyEntities db = new CurrencyEntities();
    var curMasters = db.CurrencyMasters.Where(x => x.ActiveStatus == 0);
    foreach (var item in curMasters)
    {

        var curcRatesList = DownloadCurrencyRates(fromDate, toDate, 
                                          item.FromCurrency, item.ToCurrency);

        //I know this is a bad code
        curcRatesList.Select(x =>  
                              {   
                                  db.AddToCurrencyConversions(
                                     new CurrencyEntity.CurrencyConversion { 
                                        Date = x.date, 
                                        CurrencyFactor = x.value, 
                                        FromCurrency = item.FromCurrency, 
                                        ToCurrency = item.ToCurrency 
                                      }
                                  ); 
                                  return true; 
                              }); 
    }
    db.SaveChanges();
    return DownloadStatus.DownloadSuccess;
}

How can I do the same in a proper way?
Is there any way I can do this without looping for curcRatesList?

I am using .NET 3.5, and not sure about EF version.. I didn’t try executing code(I need some other setup for that), but I am quite sure that what I am doing is not correct.. So I am posting here..

  • 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-16T15:15:58+00:00Added an answer on June 16, 2026 at 3:15 pm

    The procedure is correct. There is no bulk insert capability in EF that would allow to add a whole list of entities in a single method call. You must loop over the items and add them one by one.

    As a side note: I would just use an ordinary foreach loop instead of that strange Select trick (which misuses the Select method, but it will work). Or – if curcRatesList is of type List<T> – you can use the Foreach method of List<T> instead of Select.

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

Sidebar

Related Questions

i have 3 tables in my database and i created a entity model from
I have created a new application using Entity Framework 4.3 database migrations. The migrations
I created a new Entity Framework model from a database. This database has a
I'm pretty new to MVC 2 using the Entity Framework. I have two tables
I've created a new ASP.NET website. I've generated an Entity Data Model from my
As part of our intended migration from Linq2Sql to Entity Framework, we have created
I have some tables in a MySQL database to represent records from a sensor.
I have created a new table in the membership database. Now I want to
I have a database that was created with the Entity Framework's code first approach.
I created a simple custom attribute on the sales/order entity. Now, for new orders,

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.