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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:07:14+00:00 2026-05-15T21:07:14+00:00

I’m having an issue with updating the database. The app shows the updated value,

  • 0

I’m having an issue with updating the database. The app shows the updated value, but the database does not. No errors returned. My table has a PK. Using DotConnect for Oracle, but the LINQ syntax is the same.

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            DataContext DB = 
              new DataContext("User Id=...Password=...;Server=...;");

            DB.Log = Console.Out;
            Console.WriteLine();

            IEnumerable<Foodorder> fo = from f in DB.Foodorders
                       where f.Orderid == 10210
                       select f;
            foreach (Foodorder food in fo)
            {
              Console.WriteLine(food.Orderid + " " + food.Externalref 
                + "\r\n " + food.Orderremarks);
            }

            Console.Read();

            //Try a new connection (eliminate caching)    
            DB.Dispose();

            DataContext DB2 = new DataContext("User Id=...Password=...;Server=...;");

            Foodorder fo2 = DFunc.GetFoodOrder(10198);
            fo2.Orderremarks = "This should save now.";
            fo2.Orderqty = 9999;
            DB.SubmitChanges();

            //Retrieves a single order:  DFunc.GetFoodOrder(pk)
            Console.WriteLine(DFunc.GetFoodOrder(10198).Orderremarks);
            Console.Read();
        }
    }
}

The console reads the correct updated values, but the DB Does Not Update.

The data function, DFunc.GetFoodOrder(Oid) and data context functions are below. The are both in another assembly as the LINQ DAL:

    #region Data Context
    private static CommoDTContext cdtDataContext = new CommoDTContext(connectionSTringHere);
    /// <summary>
    /// This property gets the DevArt Oracle DotConnect data context, 
    /// providing LINQ to Oracle, and direct ORM capabilities.
    /// </summary>
    public static CommoDTContext DB
    {
        get
        {
            return cdtDataContext;
        }
        set
        {
            cdtDataContext = value;
        }
    }
    #endregion Data Context


    /// <summary>
    /// Get food order by specifying the order ID.
    /// </summary>
    /// <param name="orderId"></param>
    /// <returns></returns>
    public static Foodorder GetFoodOrder(decimal orderId)
    {   //left out validation/try-catch for brevity.
        if (orderId == 0) return null;
        var food =
            from fo in DB.Foodorders
            where fo.Orderid == orderId
            select fo;
        if (food.FirstOrDefault() == null)
            return null;
        else
            return food.FirstOrDefault();
    }
  • 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-15T21:07:14+00:00Added an answer on May 15, 2026 at 9:07 pm

    You don’t show how DFunc.GetFoodOrder(10198) is implemented. However, it doesn’t seem to have access to the data context. You also submit changes against DB after disposing. I think you meant to submit against DB2.

    In order for LINQ to do updates, the record has to be “attached” to the data context. If you query via the DataContext, the record will be attached and LINQ will track changes. Try…

    FoodOrder fo2 = DB2.Foodorders.Single(x => x.Orderid == 10198);
    fo2.Orderremarks = ...
    
    DB2.SubmitChanges();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.