Solved

How to bulk update using LINQ?

Posted on 2010-09-15
4
510 Views
Last Modified: 2012-05-10
I have a scenario where I need to update multiple records, preferably using LINQ.  For example, I need to update a list of SSRS reports that a user can view.  I  have a many-to-many junction table setup, iw_UserSSRSReport, in the database between the iw_SSRSReport and aspnet_Membership tables (see attached screenshot).

How would I insert/update the records in the junction table?  I am still in the planning stage so I haven't written any code, but I foresee an issue running into this.  

Do I need to add the User Id and SSRSReport ID to a collection and pass that to a method as a parameter, and then loop through the collection and inserting the items individually, and then calling SubmitChanges()?

And how would I update?  Would I have to first clear out the junction table where that user id exists, and then execute the same insert method?
ssrs-screenshot.png
0
Comment
Question by:markerasmus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 14

Expert Comment

by:existenz2
ID: 33689210
Are you using LINQ to Entities or LINQ to SQL? Then it shouldn't be a problem.
0
 

Author Comment

by:markerasmus
ID: 33689575
Linq to SQL.
0
 

Author Comment

by:markerasmus
ID: 33689676
Can you recommend an approach?
0
 
LVL 14

Accepted Solution

by:
existenz2 earned 500 total points
ID: 33699077
You probably have a parent child relation, so when you update the parent record you can configure that it also updates all the child records.Check http://blogs.msdn.com/b/charlie/archive/2007/02/20/one-to-many-and-joins.aspx for example.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question