积极答复者
未找到列 [Convert(LateTime,'System.Double')]是什么意思?

问题
答案
-
DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Rows.Add("11.00"); dt.Rows.Add("2.00"); dt.Rows.Add("11.00"); var value = (dt.AsEnumerable().Where(row => row["Id"]!=DBNull.Value && Convert.ToDouble(row["Id"]) > 2.0)).Sum(row => Convert.ToDouble(row["Id"])); Console.WriteLine(value);
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report- 已编辑 ThankfulHeartModerator 2013年7月3日 5:59 补充回答
- 已标记为答案 蒙田 2013年7月3日 6:17
全部回复
-
DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Rows.Add("11.00"); dt.Rows.Add("2.00"); dt.Rows.Add("11.00"); var value = (dt.AsEnumerable().Where(row => Convert.ToDouble(row["Id"]) > 2.0)).Sum(row => Convert.ToDouble(row["Id"])); Console.WriteLine(value);
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report -
DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Rows.Add("11.00"); dt.Rows.Add("2.00"); dt.Rows.Add("11.00"); var value = (dt.AsEnumerable().Where(row => Convert.ToDouble(row["Id"]) > 2.0)).Sum(row => Convert.ToDouble(row["Id"])); Console.WriteLine(value);
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report
感谢朋友的回复,我对LINQ和Lambda表达式不是很熟,如果列值有可能有空值的情况下怎么办呢? -
DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Rows.Add("11.00"); dt.Rows.Add("2.00"); dt.Rows.Add("11.00"); var value = (dt.AsEnumerable().Where(row => row["Id"]!=DBNull.Value && Convert.ToDouble(row["Id"]) > 2.0)).Sum(row => Convert.ToDouble(row["Id"])); Console.WriteLine(value);
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report- 已编辑 ThankfulHeartModerator 2013年7月3日 5:59 补充回答
- 已标记为答案 蒙田 2013年7月3日 6:17
-
DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(string)); dt.Columns.Add("Name", typeof(string)); dt.Rows.Add("11.00"); dt.Rows.Add("2.00"); dt.Rows.Add("11.00"); var value = (dt.AsEnumerable().Where(row => row["Id"]!=DBNull.Value && Convert.ToDouble(row["Id"]) > 2.0)).Sum(row => Convert.ToDouble(row["Id"])); Console.WriteLine(value);
If you think one reply solves your problem, please mark it as An Answer, if you think someone's reply helps you, please mark it as a Proposed Answer
Help by clicking:
Click here to donate your rice to the poor
Click to Donate
Click to feed Dogs & Cats
Found any spamming-senders? Please report at: Spam Report
谢谢朋友,你的方法非常好,我成功决定了三个条件下的筛选统计。