Click here to Skip to main content
14,298,693 members
Rate this:
Please Sign up or sign in to vote.
See more:
What is the equivalent SQL query fron following LINQ statement??

.DatasetProductInfo.Category.GetAccessibleRows().OrderBy(Function(x) If(Val(x.CatagoryId).Equals(0), Double.MaxValue, Val(x.CatagoryId))).ThenBy(Function(x) row.CatagoryId).Select()

Note:
Val() is the vb.net function that returns number(s) from the alphanumeric value. 
For example, Val(12foo) returns 12 only.

Thanks !
Posted
Updated 8-Sep-19 21:19pm
Rate this:
Please Sign up or sign in to vote.

Solution 1

There is a great tool called LinqPad[^]. Download, and install it. The free version will be more than enough.
prepare a proper data connextion so you can execute your LINQ query. At that point click to the "SQL" view, and you will see the generated SQL statements (like here[^]).

But if this query runs on LINQ to Objects bot not on LINQ to EF or LINQ to SQL, it won't run in LinqPad either. In this case you will probably need to use some SqlFunctions[^], or if this is not enough. If this is still not enough, you can have a first pass on SQL/EF (by filtering as much as you can), than after a ToList() you have everything that's available on Objects as a second pass.
   
v2
Rate this:
Please Sign up or sign in to vote.

Solution 4

How to Convert SQL statement to LINQ statement can u help in it. I couldn't find the LINQ option in Result window.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100