Question

I'm currently using Entity Framework 4.3, Asp.Net 4.0, Sql Server 2008 Web.

I have method that loops through 10 to 20 loan providers. Each loan provider has a chance to bid for the loan - if they do the loop terminates - if not, they loop continues until all loan providers are consumed and a "no offers" message is returned.

I want to start logging this data - simply the lender and customer ID's. So for each customer who submits an application there maybe 1 to 20 inserts to perform. I can save these in a list and update them in 1 go.

As I'm using EF, I'm a little concerned about performance - I presume an insert will be done for each separate item added to the context.

Firstly - should I be worried about performance? Secondly, are there any techniques I can use to make this process more efficient?

Thanks in advance.

Was it helpful?

Solution

This has nothing to do with Entity Framework. You must insert one row at a time in SQL, that's the way SQL works. Each insert is a separate statement. There is no way (outside of special bulk-insert methods, which would be pointless for 20 records) of doing it differently.

Now, yes, you can insert those 20 records in one request, which is what EF will do.

I don't understand you comment "As I'm using EF, I'm a little concerned about performance". EF is no worse performing than anything else in this respect. It's a simple 20 record insert, there's nothing special here or any complexity that could cause performance issues.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top