score:0
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
score:1
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.
Source: stackoverflow.com
Related Query
- LINQ to Entities string to decimal a column
- linq to entities changing database connection string in code
- Linq to entities / EF : join to tables on a decimal and a string field
- Concatenate int and string in LINQ to Entities
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Convert string to decimal in group join linq query
- Dynamic LINQ DateTime Comparison String Building - Linq To Entities
- LINQ to Entities - How to return a single string value from entity
- LINQ to Entities - DISTINCT on one column
- LINQ to Entities split string on result
- linq join on guid and string column
- LINQ Source Code Available
- Creating a LINQ Select expression dynamically from string column names
- Linq Order by when column name is dynamic and pass as a string to a function
- Refactor Linq code and "LINQ to Entities does not recognize the method"
- The given value of type String from the data source cannot be converted to type int of the specified target column
- Perform string search with Linq to Entities
- How to read a string with UTF8 coding using linq to entities
- LINQ compare string and DB column type 'text'
- Sum a string column in linq
- how to convert int to string in Linq to entities
- creating Linq to sqlite dbml from DbLinq source code
- EF Code First - Linq to Entities Union EqualityComparer
- Linq to entities - first letter of string between 2 keys
- Cannot convert type string to decimal in linq query
- linq to entities can not convert int to string
- How to convert a string to decimal in a LINQ query
- LINQ - Accessing a column with the column name as a string parameter
- How to compare a string column to a number (as a decimal) in Linq
- how to get two column values in a single query using linq to entities
More Query from same tag
- Linq count trouble
- linq to sql row number per group
- How to execute a LINQ statement without assigning it to a variable?
- test if property in entity can be ordered using orderBy
- Join data from IQueryable and IList<KeyValuePair>
- linq to entities group by sub-query
- Error in Linq Pivot query
- how to use .Contains LINQ in decimal fields
- Get another class from LINQ to SQL query
- Group by 2 out of 3 columns
- linq join, group by to get count of child table
- Linq with dynamics "where parameter"
- Expression<Func<T, bool>> from a F# func
- How can I compare two IEnumerable<> objects and return a new one?
- Linq query to orderby level then parent and child item
- First called method faster than second one
- Ordering list by many conditions using Linq
- Inline method that support translation to sql
- Am I using LINQ correctly to apply a variable amount of filters?
- Lambda Aggregate Expression C#
- Load XML into grid view
- dynamic where clause with array
- LINQ Find String Duplicates in List
- Sorting List<Struct> items by order of int variable in each struct
- How to consolidate a Dictionary with multiple (three) keys by reducing one or more key and merging the multiple records (if any) into one single one?
- c# Sorting a Custom List
- Displaying Custom Fields in LINQ to Entity Dynamic Select
- C# Looping through nested LINQ select statements
- without for loop how can is show var type these value in TextBox
- Associate values of one list with the ones of another list with linq