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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:24:30+00:00 2026-06-04T10:24:30+00:00

I am creating a WebAPI where the frontend will send back a list of

  • 0

I am creating a WebAPI where the frontend will send back a list of entities. Some of which may already exist.

    public void AddTags( List<Tag> tags) //input coming from frontend js
    {
        foreach(Tag tag in tags){
          //check if tag exists in db
          //if not, create one

        }
    }

I tried to use DbContext.Tags.Contains(tag) but I am not sure how to link tag with the existing tag entity in the database.

I am trying to do something similar to below:

Tag tag = new Tag();
tag.name = "foo";
tag.someProp1= "hello";
tag.someProp2= "world";
tag.someProp3= "123";
//tag.id = unique id is unknown, decided by db
//find an identical entity exists in db, link `tag` to it
//if no such entity exists, add to DbContext.Tags

I am looking for something like DbContext.Tags.Match(tag); Where given an entity, it’s looking for an identical one in db.

  • 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-04T10:24:32+00:00Added an answer on June 4, 2026 at 10:24 am

    This may work for you. I assume that Tag has some type of unique identifier (either an Id or Name property perhaps). So you can always do something like this:

    DBContext.Tags.Where(t => t.Id == tag.Id);

    Would that work for you?

    UPDATE

    Based on your comment above, I’m not sure what you are after. If you are only ‘adding’ then you don’t need to check if the Tags exist, correct?

    If you know what you want to match against, you can do this yes?

    DBContext.Tags.Where(t => t.name == tag.name && t.prop1 == tag.prop1).FirstOrDefault();

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

Sidebar

Related Questions

I'm creating a webApp in which I show some table data using jQuery and
Creating a server-side socket will fail if I'm trying to use the same port
I am creating a webapp in Spring and I faced a problem which is
I'm creating a webapp to be used by iOS users, but some phone numbers
I am creating a simple web API that returns JSON. It will perform simple
I have a Java webapp creating a pdf and streaming it back to the
We've been working on a webapp for some time now which is designed to
I'm creating an iPhone app that will pull data down from a Web API,
I'm creating a webapp with MS MVC3 on the back, and jquery etc on
I'm creating a webapp where upon connecting to my server, you will have one

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.