In the standard DevExtreme template, there is a class Orders.cs. And there is SampleData.cs, ​​which added a dozen attributes. Great idea, I thought. There is very little data in my project. But from time to time they can change. I do not want to bother with setting up SQL Server for 10 records. I want to store attributes in the same form, but with the possibility of CRUD.
Having seen a record of this kind in one of the guides, I was already reassured

comps.Add(new FormInputs { Id = 1, name = "name", optional = false, placeholder = "Введите ФИО", type="dxTextBox" }); 

I thought this construct will add a new entry to the class, but it is not. It adds it only to the variable.

  • can be looked in the direction of SQLite | Sql Compact - Bald
  • @Bald

1 answer 1

If you want to save the data, simply serialize the object of the class you need and save it to the permanent storage, and restore it before use. You can for example use the Json.Net library.

 Product product = new Product(); product.Name = "Apple"; product.ExpiryDate = new DateTime(2008, 12, 28); product.Price = 3.99M; product.Sizes = new string[] { "Small", "Medium", "Large" }; string output = JsonConvert.SerializeObject(product); //{ // "Name": "Apple", // "ExpiryDate": "2008-12-28T00:00:00", // "Price": 3.99, // "Sizes": [ // "Small", // "Medium", // "Large" // ] //} Product deserializedProduct = JsonConvert.DeserializeObject<Product>(output);