0

I was assigned to upgrade a web application that was created a long time ago. In that project, data in the database was access and modify and return with a dynamic list. The relationship of some items between tables was not related by Id but rather by their title. It returns me with a list of items in which column title was assigned by item title that unfortunately contain accented letters.

Exammple item return

enter image description here

I can't access these kinds of data since accented letters are either forbidden by coding rule or there's a way but I don't know how to use it, yet. I have tried the following code, surrounding those letters with [] but it doesn't work.

var maBuonList = list.Select(x => x.["Ẩm_Bã bùn"]).ToList();

I have also tried query without dot but it returns me with another error.

var maBuonList = list.Select(x => x["Ẩm_Bã bùn"]).ToList();

The error:

'Cannot apply indexing with [] to an expression of type 'System.Dynamic.ExpandoObject''

Error without dot

Error without dot

Svyatoslav Danyliv
  • 21,911
  • 3
  • 16
  • 32

1 Answers1

0

If you are getting list from db,you can use Column,and get List<SampleModel> rather than List<dynamic>:

public class SampleModel {
        public string Gio { get; set; }
        [Column("Ẩm_Bã bùn")]
        public double Ẩm_Bã_bùn { get; set; }


    }
Yiyi You
  • 16,875
  • 1
  • 10
  • 22