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 :
Errors I get : Nothing changes when I change the data of the dictionary even though i had link them together.
Dictionary : [{"name":"Jamie","totalexp ense":"13. 09"}]
Columns : Name, Total Expense
Current output
Expected Output
I would like to have the columns to be updated when the dictionary fields are changed
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;
}
Errors I get : Nothing changes when I change the data of the dictionary even though i had link them together.
Dictionary : [{"name":"Jamie","totalexp
Columns : Name, Total Expense
Current output
Expected Output
I would like to have the columns to be updated when the dictionary fields are changed
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You have to write the code to do that yourself