I have a c# webforms application that uses Linq2SQL, SQL Server, .net 4.5
I know SQL reasonably well, but am finding Linq very hard work.
SQL although tricky usually makes sense, but I find linq almost impossible to write unless I can find a identical example online. This time I cannot find one.
I am using a view within the SQL to simplify the process and cut out the need for insane linq syntax joining tables together, however as views won't allow ORDER BY statements I am a bit stuck. I can get the query to work perfectly in a stored procedure, but I gave up trying to get the data back through linq after 5-hours scouring of the 'Net to find out how.
The original ORDER BY sorts the Name column but ignores a "The " at the start of the field giving:
Apple
The Banana
Orange
Pear
Here is the SQL query:
SELECT TOP 100 Name, Year, Data1, Data2
FROM v_List_Items
ORDER BY
CASE WHEN LOWER(SUBSTRING(Name, 1, 4)) = 'the '
THEN SUBSTRING(Name, 5, len(Name))
ELSE NAME
END ASC
Any ideas ?
Also being able to change the 100 results filter dynamically would be useful.
Thanks
OrderBylambda?Theprefix.