转换"浮动"在DataSet中从SQL到" float"在Web API中

时间:2016-07-01 18:04:16

标签: sql-server asp.net-mvc asp.net-web-api

我在将数据集ds从SQL服务器转换为Web API中的对象时遇到问题。问题只出在" float"存在于数据集(ds)中。我试图将数据集(ds)转换为对象列表。但它会为所有" float"抛出一个错误。如果我排除所有浮动,它就可以正常工作。

private static List<TimesheetDetails> ProcessInfo(DataSet ds)


        {
            bool check = (ds == null);
            List<TimesheetDetails> list = ds.Tables[0].AsEnumerable().Select(x => new TimesheetDetails
            {
                DetailId = x.Field<int>("DetailId"),
                TimesheetId = x.Field<int>("TimesheetId"),
                Project = x.Field<string>("Project"),
                Ac`enter code here`tivity = x.Field<string>("Activity"),
                Day1 = x.Field<DateTime> ("Day1"),
                **//The Issue comes up here when I try to access the float.**
                Day1Hours = x.Field<float> ("Day1Hours"),
                Day2 = x.Field<DateTime>("Day2"),
                Day2Hours = x.Field<float>("Day2Hours"),
                Day3 = x.Field<DateTime>("Day3"),
                Day3Hours = x.Field<float>("Day3Hours"),
                Day4 = x.Field<DateTime>("Day4"),
                Day4Hours = x.Field<float>("Day4Hours"),
                Day5 = x.Field<DateTime>("Day5"),
                Day5Hours = x.Field<float>("Day5Hours"),
                Day6 = x.Field<DateTime>("Day6"),
                Day6Hours = x.Field<float>("Day6Hours"),
                Day7 = x.Field<DateTime>("Day7"),
                Day7Hours = x.Field<float>("Day7Hours")
            }).ToList();

0 个答案:

没有答案