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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:55:21+00:00 2026-05-12T23:55:21+00:00

Suppose you have this table structure: Patient -> PatientTag -> Tag A typical N:M

  • 0

Suppose you have this table structure:

Patient -> PatientTag -> Tag

A typical N:M relationship between patients and tags, PatientTag being the intermediate entity with both FKs. (PatientId and TagId).

I want to remove a specific tag, I have its ID. I’m doing this but I’d like to know if there’s a better way, since these are the 1st methods I write using PLINQO, I wouldn’t want to create bad practices from the beginning.

            using ( MyDataContext dc = DataContextFactory.GetDataContext() )
            {

                var options = new DataLoadOptions();
                options.LoadWith<Paciente>(p => p.PacienteTagList);
                options.LoadWith<PacienteTag>(pt => pt.Tag);
                dc.LoadOptions = options;

                // Get the Tag we're going to remove from the DB.
                var tag = dc.Manager.Tag.GetByKey( idTag);

                // Remove each patient from the association. 
                foreach ( Paciente pac in tag.PacienteList1 )
                {
                    // we need to retrieve it, won’t let us use the ‘pac’ object.
                    var pax = dc.Manager.Paciente.GetByKey( pac.IdPaciente );
                    pax.TagList.Remove(tag);
                }

                // now remove the tag
                dc.Manager.Tag.Delete(tag.TagId);

                // And commit the changes
                dc.SubmitChanges();
            }

Thanks for any insight on the subject.

  • 1 1 Answer
  • 4 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-12T23:55:21+00:00Added an answer on May 12, 2026 at 11:55 pm

    What about simply using a foreign key with cascading delete, then deleting the tag itself and letting the database take care of deleting all the references. If you wanted to make sure that it wasn’t in use, you could check that there aren’t any patients associated with it first, though you may need to wrap it in a transaction if there are other processes accessing the same database.

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

Sidebar

Related Questions

Suppose I have this database table (some sample code below) that stores the relationship
Suppose you have a table like this: id user score It's a dump of
For the sake of this question, let's suppose this table structure: People: PersonID int
Suppose I have a table, Foo, that looks like this: ID | Name |
I have a data.table object like this one library(data.table) a <- structure(list(PERMNO = c(10006L,
Suppose I have 2 tables in a database. eg: Dog & Boss This is
Suppose I have this (C++ or maybe C) code: vector<int> my_vector; for (int i
Suppose I have this function: void my_test() { A a1 = A_factory_func(); A a2(A_factory_func());
Suppose I have this feature branch foo. Now I want to merge it back
Suppose I have this: <select id=myselect> <option rel=a>1</option> <option rel=b>2</option> <select> How do I

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.