I have some C# examples here, which i actually want to know how i can optimize them. I want to cut down the codeexample to the minimum. Is there a practical way to refactor the GetDetails
in the Tour
class or should i refactor it in the CombiTour
class? And of course, how can i refactor it.
public class Tour
{
public string zielID;
public string ort;
public string strasse;
public string nummer;
public string plz;
public string land;
public string name;
public string fahrtNummer;
public Tour(string zielID)
{
this.zielID = zielID;
}
}
public class CombiTour
{
public List<Tour> touren;
public CombiTour()
{
this.touren = new List<Tour>();
}
public void GetDetails()
{
for (int i = 0; i < touren.Count; i++)
{
DataSet dsDetails = Tools.oGenericDs("SELECT Strasse, Nummer, PLZ, Ort, Land, Fahrtnummer FROM Ziele WHERE ZielID = " + this.touren[i].ZielID);
this.touren[i].Strasse = dsDetails.Tables[0].Rows[0]["Strasse"].ToString();
this.touren[i].Nummer = dsDetails.Tables[0].Rows[0]["Nummer"].ToString();
this.touren[i].PLZ = dsDetails.Tables[0].Rows[0]["PLZ"].ToString();
this.touren[i].Ort = dsDetails.Tables[0].Rows[0]["Ort"].ToString();
this.touren[i].Land = dsDetails.Tables[0].Rows[0]["Land"].ToString();
this.touren[i].Fahrtnummer = dsDetails.Tables[0].Rows[0]["Fahrtnummer"].ToString();
dsDetails = Tools.oGenericDs("SELECT Name FROM Kunden WHERE ZielID = " + this.touren[i].ZielID);
this.touren[i].Name = dsDetails.Tables[0].Rows[0]["Name"].ToString();
}
}
}