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

The Archive Base Latest Questions

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

I am using Linq to SQL in a two tier project where the server

  • 0

I am using Linq to SQL in a two tier project where the server tier abstracts the DB and is using Linq to SQL.
In my client tier I construct an object and I send to the server.

I have a Task, which has a relationship to Reporter (who reported this task), so Task has a ReportedID column in the database, which is a FK to Reporter.ID.

In the Linq abstraction, my Task has a Reporter property and a ReportedID property.

To save new Tasks, I would like to use the ReportedID, so I have this code:

//Populate the object with the info
        Task task = new Task();
        task.Title = tbTitle.Text;
        task.Description = tbDescription.Text;
        task.Severity = ((Severity)lbSeverities.SelectedItem);
        //the first state: "open"
        task.StateID = 1;

        //TODO - Set ReporterID
        task.ReporterID = 1;


        //Save the task
        client.SaveTaskCompleted += new EventHandler<SaveTaskCompletedEventArgs>(client_SaveTaskCompleted);
        client.SaveTaskAsync(App.Token, task);

So, the object is constructed and sent to the server, where it is saved using this code:

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

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

        return task;
    }

The problem is that I get an exception: “An attempt was made to remove a relationship between a Reporter and a Task. However, one of the relationship’s foreign keys (Task.ReporterID) cannot be set to null.”.
If I use the Reporter property, it works.
What am I doing wrong?

Thank you,
Oscar

  • 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-19T01:18:32+00:00Added an answer on May 19, 2026 at 1:18 am

    I made some refactory in my code and this error doesn’t anymore. It may be a logic error but I can’t tell exactly what.

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

Sidebar

Related Questions

I'm using LINQ to SQL and C#. I have two LINQ classes: User and
I have started using Linq to SQL in a (bit DDD like) system which
I have two tables that I am using Linq to SQL with. The tables
How do I properly convert two columns from SQL (2008) using Linq into a
Using LINQ to SQL, I have an Order class with a collection of OrderDetails.
I'm using LINQ to SQL classes in a project where the database design is
I am using LINQ to SQL for my website to access two databases. The
I am using Linq-to-SQL (C# 3.5) to read two tables, house and county, from
I am returning two lists from the database using LINQ to SQL compiled query.
I'm using Linq to Sql and have a Many-To-Many relation and therefore use a

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.