linq を使用して double 値を取得し、それを文字列に変換するときに問題が発生します。私のコードは次のとおりです:-
public List<ShowDataOnClient> GetCardListToShow()
{
try
{
List<ShowDataOnClient> CardList = new List<ShowDataOnClient>();
using (ProgressCardLINQDataContext c = new ProgressCardLINQDataContext())
{
CardList = (from card in c.GetTable<T_PROGRESSCARD>()
where card.RecordStatus.Equals(RecordStatus.Active)
select new ShowDataOnClient
{
Student=(from student in c.T_STUDENTs
where student.Id.Equals(card.StudentId)
select student.Name).Single().ToString(),
Test=(from test in c.T_TESTs
where test.Id.Equals(card.TestId)
select test.Name).Single().ToString(),
MaxMarks = (from test in c.T_TESTs
where test.Id.Equals(card.TestId)
select test.MaxMarks).Single().ToString(),
MarksObtain=card.MarksObtain.ToString(),
Percentage=card.Percentage.ToString()
}).ToList<ShowDataOnClient>();
}
return CardList;
}
catch
{
return new List<ShowDataOnClient>();
}
}
私もこれを試しました: -
Percentage=Math.Truncate(card.Percentage).ToString()
ToStringに「N2」を渡すと、「メソッド 'System.String ToString(System.String)' has no supported translation to SQL.」という例外が発生します。
変換後に得た値は次のようになります:- 5.200000000000000e+001
私を助けてくれる人はいますか..