Ive got the following LINQ query:-
(from a in MyData
where a.Field1.Replace(" ","").Contains("ABCDEFG")
select a.Field2).Take(50)
It returns:-
114
115
115 A
116
116 A
118
119
122
124
128
131
132
133
95
96
97
98
99
I need to be able to sort this list numerically which i could do like this:-
(from a in MyData
where a.Field1.Replace(" ","").Contains("ABCDEFG")
select a.Field2).Take(50).OrderBy(x => Convert.ToInt32(x))
Problem is this returns:-
Conversion failed when converting the nvarchar value '111 A ' to data type int.
Because it obviously cannot convert the '111 A '
to an integer.
Is there any way of stripping out all non-numeric characters just for the sorting ?