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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:30:38+00:00 2026-05-18T22:30:38+00:00

I am still facing some problems when using LINQ-to-SQL. I am also looking for

  • 0

I am still facing some problems when using LINQ-to-SQL.
I am also looking for answers by myself, but this problem is so akward that I am having problems to find the right keywords to look for it.

I have this code here:

public CustomTask SaveTask(string token, CustomTask task)
    {
        TrackingDataContext dataConext = new TrackingDataContext();

        //Check the token for security
        if (SessionTokenBase.Instance.ExistsToken(Convert.ToInt32(token)) == null) return null;

        //Populates the Task - the "real" Linq to SQL object            
        Task t = new Task();
        t.Title = task.Title;
        t.Description = task.Description;

//****The next 4 lines are important****
        if (task.Severity != null)
            t.Severity = task.Severity;
        else
            t.SeverityID = task.SeverityID;

        t.StateID = task.StateID;

        if (task.TeamMember != null)
            t.TeamMember = task.TeamMember;
        else
            t.ReporterID = task.ReporterID;

        if (task.ReporterTeam != null)
            t.Team = task.ReporterTeam;
        else
            t.ReporterTeamID = task.ReporterTeamID;

        //Saves/Updates the task
        dataConext.Tasks.InsertOnSubmit(t);
        dataConext.SubmitChanges();

        task.ID = t.ID;

        return task;
    }

The problem is that I am sending the the severity, and then, when I get this situation:

DB State before calling the method:

ID Name
1 high
2 medium
3 low

Call the method selecting “medium” as severity

DB State after calling the method:
ID Name
1 high
2 medium
3 low
4 medium

The point is:
-Why is it duplicating this entry??

Some explanation about the code:
CustomTask is almost the same as Task, but I was having problems regarding serialization as can be seen here

Edit: just found out that the code is sending an Severity object and not the ID, I am going to change it. But it is still very strange that it duplicates the entry 🙁

Edit2: Updated the question due to new information

  • 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-18T22:30:38+00:00Added an answer on May 18, 2026 at 10:30 pm

    The problems was that the services are Rest, so a new DataContext is created every call, generating the duplicated entry.
    Using the ID avoids this problem.

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

Sidebar

Related Questions

I am facing some problems converting the PHP SQL insertion code below to ASP,
I am facing an application that uses hashing, but I cannot still figure out
still new to the world of linq, and i need some help flatening a
I am facing a very basic problem. Some time small things can take your
I am using Listview,the View selected is largeicon mode. The problem i am facing
The problem I'm facing is that I'm trying to manipulate (in this particular case
I find myself again and again faced with a similar problem: there's some piece
Still new to Objective C, and I'm having some trouble that I just can't
I still very new using Subversion. Is it possible to have a working copy
Okay still fighting with doing some SqlCacheDependecy in my Asp.net MVC application I got

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.