linq 指定的轉換無效_轉型

  • 433
  • 0
  • 2018-01-29

linq 指定的轉換無效_轉型


 




sql =@"
select 
	(
	substring(
		cast(
			convert(decimal(20,10),tb2.score_x) + convert(decimal(20,10),tb2.score_paper) + convert(decimal(20,10),tb2.score_intvi) + convert(decimal(20,10),tb2.score_imple) 
			as varchar
		)
	,1
	,charindex('.', cast(score_x as varchar))+2)
	)AS 'score_sum'
form
	table
";

cmd.CommandText = sql;
apt = new SqlDataAdapter(cmd);
dt = new DataTable();
apt.Fill(dt);

dt = (from temp_dt in dt.AsEnumerable()
	  orderby Convert.ToDecimal(temp_dt.Field<string>("score_sum")) descending
	  select temp_dt).CopyToDataTable();