Autor Beitrag
dinazavric
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75



BeitragVerfasst: Mo 13.06.11 11:11 
Hallo,

irgendwie komm ich mit Zeilen/Spalten durcheinander... Ich habe eine Tabelle "ParameterValues":

- ParameterName
- ValueDefinition

Nehmen wir an, es wurden zwei ValueDefinitionen mit demselben ParameterNamen gespeichert. Nun möchte ich den ersten Wert als "min" und den zweiten als "max" speichern. Was muss ich dann übergeben?
Vielen Dank im Voraus!

ausblenden C#-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
int min = 0, max = 0;

foreach (DataRow dataRow in dataSetPro.Tables["ParameterValues"].Rows)
{
  if (dataRow["ParameterName"].ToString() == NameControls[i].Text)
  {
    min = ...;
    max = ...;
  }
}
Trashkid2000
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 561
Erhaltene Danke: 137



BeitragVerfasst: Di 14.06.11 08:46 
Hallo,
das Ganze in einer Schleife zu machen macht einfach keinen Sinn.
Du könntest das schnell per LinQ lösen:
ausblenden C#-Quelltext
1:
2:
3:
var values = dt.Rows.OfType<DataRow>().Where(x => x.Field<string>("ParameterName") == NameControls[i].Text);
int minValue = values.Min(x => x.Field<int>("ValueDefinition"));
int MaxValue = values.Max(x => x.Field<int>("ValueDefinition"));

LG
dinazavric Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 75



BeitragVerfasst: Di 14.06.11 09:49 
Danke, werde ich ausprobieren :-)