© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
31 replies
_vegabyte_

❔ Saving a JSON object to Database

HI. I want to save a Array to Database but I'm this error.

"Error getting value from 'Values' on 'ELIXIR.DATA.DATA_ACCESS_LAYER.MODELS.QC_CHECKLIST.CheckListString'.",
"Error getting value from 'Values' on 'ELIXIR.DATA.DATA_ACCESS_LAYER.MODELS.QC_CHECKLIST.CheckListString'.",

 public class CheckListString
    {
        [Key]
        public int ChecklistStringId { get; set; }
        public int? PO_Summary_Id { get; set; }
        public int? ReceivingId { get; set; }
        public string Checlist_Type { get; set; }

        [NotMapped]
        public List<string> Values
        {
            get => JsonSerializer.Deserialize<List<string>>(Value);
            set => Value = JsonSerializer.Serialize(value);
        }
        public string Value { get; set; }

        public string Remarks { get; set; }
    }
 public class CheckListString
    {
        [Key]
        public int ChecklistStringId { get; set; }
        public int? PO_Summary_Id { get; set; }
        public int? ReceivingId { get; set; }
        public string Checlist_Type { get; set; }

        [NotMapped]
        public List<string> Values
        {
            get => JsonSerializer.Deserialize<List<string>>(Value);
            set => Value = JsonSerializer.Serialize(value);
        }
        public string Value { get; set; }

        public string Remarks { get; set; }
    }

public async Task<bool> AddChecklists(Checklists input)
        {
            foreach (var checklistString in input.ChecklistsString)
            {
                var newChecklistString = new CheckListString
                {
                    PO_Summary_Id = checklistString.PO_Summary_Id,
                    Checlist_Type = checklistString.Checlist_Type,
                    Values = checklistString.Values,
                    Remarks = checklistString.Remarks
                };
                await _context.CheckListStrings.AddAsync(newChecklistString);
            }

            await _context.SaveChangesAsync();

            return true;
        }
public async Task<bool> AddChecklists(Checklists input)
        {
            foreach (var checklistString in input.ChecklistsString)
            {
                var newChecklistString = new CheckListString
                {
                    PO_Summary_Id = checklistString.PO_Summary_Id,
                    Checlist_Type = checklistString.Checlist_Type,
                    Values = checklistString.Values,
                    Remarks = checklistString.Remarks
                };
                await _context.CheckListStrings.AddAsync(newChecklistString);
            }

            await _context.SaveChangesAsync();

            return true;
        }


This is the body
{
  "checklistsString": [
    {
      "checklistStringId": 0,
      "pO_Summary_Id": 0,
      "receivingId": 0,
      "checlist_Type": "string",
      "values": [
        "string"
      ],
      "value": "string",
      "remarks": "string"
    }
  ]
}
{
  "checklistsString": [
    {
      "checklistStringId": 0,
      "pO_Summary_Id": 0,
      "receivingId": 0,
      "checlist_Type": "string",
      "values": [
        "string"
      ],
      "value": "string",
      "remarks": "string"
    }
  ]
}

Any help will be much appreciated
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Json saving / Loading help
C#CC# / help
3y ago
✅ Saving api json data to db
C#CC# / help
3y ago