I have researched this question to death. Everyone and their brother wants to know how to convert an int or decimal to string, but I can\'t find any example of doing the op
You have to get the data to a List<Order>
first and after that you can cast whatever you want.
var orders =
from s in
((from o in db.Orders
where o.Order_Complete
select o).ToList())
select new {
s.Order_Id,
s.MySEL_Name,
s.MySEL_EMail,
s.MySEL_Bus_Name,
Double.Parse(s.Total_Amt),
s.Order_Complete_DateTime
};
I think the EMS way would look much better in your code ;)
var orders =
db.Orders.Where(s => s.Order_Complete).ToList().Select(s => new { /*...*/ }
After casting ToList()
you have got the data object based and can modify it, if you don't you can use Double.Parse
because EF is trying to find e.g. a stored procedure on the database and will throw an exception.
Have you tried model-defined functions?
<Function Name="ConvertToDecimal" ReturnType="Edm.Decimal">
<Parameter Name="myStr" Type="Edm.String" />
<DefiningExpression>
CAST(myStr AS Edm.Decimal(12, 2))
</DefiningExpression>
</Function>
Check this answer: Convert string to decimal in group join linq query