私はモデルを持っています:
public class KPIResults
{
public virtual string Title { get; set; }
public virtual int Total { get; set; }
public virtual int Week6 { get; set; }
public virtual int Week5 { get; set; }
public virtual int Week4 { get; set; }
public virtual int Week3 { get; set; }
public virtual int Week2 { get; set; }
public virtual int Week1 { get; set; }
public virtual string stringWeek6 { get; set; }
public virtual string stringWeek5 { get; set; }
public virtual string stringWeek4 { get; set; }
public virtual string stringWeek3 { get; set; }
public virtual string stringWeek2 { get; set; }
public virtual string stringWeek1 { get; set; }
}
私のレポートリポジトリには次のものがあります。
int strfound = 0;
string str = "Number";
foreach (DataRow dr in dt.Rows)
{
string title = dr["Title"].ToString();
int total = Convert.ToInt32(dr["Total"]);
if (dr["Week6"].contains("Number") //synntacs not right?
var week6 = dr["strWeek6"]
end
or do this:
strfound = str.IndexOf(dr); //syntacs not right?
if (strfound == 0)
{
var week6 = dr["strWeek6"]
}
var week6 = Convert.ToInt32(dr["Week6"]);
var week5 = Convert.ToInt32(dr["Week5"]);
var week4 = Convert.ToInt32(dr["Week4"]);
var week3 = Convert.ToInt32(dr["Week3"]);
var week2 = Convert.ToInt32(dr["Week2"]);
var week1 = Convert.ToInt32(dr["Week1"]);
results.Add(new KPIResults() {Title = title, Total = total, Week6 = week6, Week5 = week5, Week4 = week4, Week3 = week3, Week2 = week2, Week1 = week1});
}
return results;
文字列検索を試してみる必要があるかもしれませんが、isのコードが正しくありません。文字列を処理する方法を探していますが、明確ではありません。
ありがとう