Link to home
Start Free TrialLog in
Avatar of help needed
help needed

asked on

Linking dictionary and columns together

I would like to know how could I link values that are in a dictionary to columns that are in another table. Both of them are in the same database. Thank you. The software I am using is Microsoft visual studio.

These are my codes to link them :

   
 public bool linkTgt()
    {
        //retrieve the columns in Claim Table
        var allData = db.Claim.ToList();
        // create the dictionary to be able to have a space to add each variable 
        var dic = new List<Dictionary<string, string>>();
        //to save each variable information
        Dictionary<string, string> eachLine = new Dictionary<string, string>();

        foreach (var expence in db.Expence)
        {


            //to check if there is this key in the dictionary called dic
            var key = "name";
            if (eachLine.ContainsKey(key))
            {
                string name = eachLine["name"];
                //if there is then the value of column in expence table is equal to the value in the dictionary
                expence.Name = name;

            }
            //Add it back to the dictionary field
            DataSheet.Add(eachLine);

        }
        //save the changes 
        db.SaveChanges();
        return true;
    }

Open in new window


Errors I get : Nothing changes when I change the data of the dictionary even though i had link them together.

Dictionary : [{"name":"Jamie","totalexpense":"13.09"}]

Columns : Name, Total Expense

Current output

Expected OutputUser generated image
I would like to have the columns to be updated when the dictionary fields are changed
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

>>I would like to have the columns to be updated when the dictionary fields are changed
You have to write the code to do that yourself
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial