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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:18:43+00:00 2026-05-19T13:18:43+00:00

I have a screen in which the user can select which categories they want

  • 0

I have a screen in which the user can select which categories they want to subscribe to. They can select zero to many categories. These get stored in a UserCategory table, which has a userid and a category id.

So, if the user select 2 out of the 8 categories, I write two rows, with the category ids and the userid.

(He is now assigned to TWO categories)

However, if the user returns, and deselects one of the categories, and then adds 2 different categories, he is now assigned to 3 categories…

But I’m unsure of a good way to handle this in linq… Somehow, I need to do something like … DELETE FROM UserCategories where userId = :UserId and CategoryId NOT IN the int[] of category ids passed in…. And then I need to INSERT INTO UserCategories … the int[] category ids, but not the ones that already exist.

And I need to do it in Linq, using Entity Framework… Can someone assist?

  • 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-19T13:18:44+00:00Added an answer on May 19, 2026 at 1:18 pm

    The simplest solution might be to remove the user from all current categories and re-add to those that are still selected. While you are potentially removing and adding the same information again, it keeps the code simpler and simpler code is easier to maintain.

    So you’d read the current information from the database and present that on the form. Then when the user hits “OK” clear current information in the database (keeping the copy in memory of course) and then add it back as though it was the first time through the code.

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

Sidebar

Related Questions

I have a Product edit screen. The user can select a Vendor for the
I have a process which gives me continuously output in Screen. I want to
I have a screen capturing utility on which I can rubber band an area
I have several uiimageviews on my view which the user can drag around. I
Java 1.5, Linux I do have a screen which contains different textareas and textfields.
I basically have a page which shows a processing screen which has been flushed
There are lots of java apps on my simulator menu screen which I have
I have been asked to write an app which screen scrapes info from an
i have this GUI screen shots from the design team which i needs to
I have a WPF app which snaps to screen edges (I just set the

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.