I take information from the database, when I get fields, I get a lot
dreader["field_name"].ToString()
Is it possible to translate DataReader into Dictionary right away to get rid of the ToString () heap ?:
drDict["field_name"]

UPD:

did so:
Dictionary<string, object> drDict; drDict = Enumerable.Range(0, dr.FieldCount).ToDictionary(dr.GetName, dr.GetValue); but the value is object, again you need to cast it in string

  • immediately how? - tym32167
  • @ tym32167 added to the question - axmed2004
  • Well, cast dr.GetValue.ToString() - tym32167 here
  • @ tym32167 'OleDbDataReader.GetValue (int) "is a method that is not allowed in this context. ToDictionary(dr.GetName, (string)dr.GetValue) also an error - axmed2004
  • Well, before you worked like this, add to .ToString() - tym32167

0