Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
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

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.
 
Share this answer
 
v2
How to Convert SQL statement to LINQ statement can u help in it. I couldn't find the LINQ option in Result window.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900