this is my query in sql server and everything works fine
select * from DetalleNotas
order by len(ColProduct), ColProduct
PROCT1
PROCT2
PROCT3
PROCT4
PROCT5
PROCT6
PROCT7
PROCT8
PROCT9
PROCT10
but i want my query in linq
I tried this and it doesn't work
var product = (from d in db.Product
orderby len(d.ColProduct), d.ColProduct
select new
{
product= d.product
});
only this query works
var product = (from d in db.Product
orderby d.ColProduct
select new
{
product= d.product
});
This is the result of my functional query
PROCT1
PROCT10
PROCT2
PROCT3
PROCT4
PROCT5
PROCT6
PROCT7
PROCT8
PROCT9
You might want to do the
orderby
by:If
d.ColProduct
it is of typestring
, below an example:I did the above example on a
List<string>
, but it is the same if you make the modification that I mentioned a moment ago, this is the result that it gives me:Applying it to your query would be:
Here's a fiddle for you to try, greetings! :)