Ahmed Saif
Ahmed Saif

Reputation: 23

How convert linq query to SQL query?

I want convert following LINQ query to SQL query.

var ACTIVITY_ROYALITY_MONTH = from m in db.MiningPermit
                                      join pm in db.Permit_Mineral on m.MINING_PERMIT_ID equals pm.MINING_PERMIT_ID
                                      join r in db.Royality on pm.Permit_Minerals_ID equals r.Permit_Minerals_ID
                                      where r.ORDER_ID == 0 // NULL in server
                                      orderby r.YEAR, r.MONTH
                                      group r by new { m.MINING_PERMIT_ID , r.YEAR, r.MONTH }  into mpmr
                                      select mpmr.ToList();

Upvotes: 0

Views: 6711

Answers (1)

ΩmegaMan
ΩmegaMan

Reputation: 31596

Use Linqpad and recreate the linq (even by bringing in your assemblies) in a C# query. Run the query. Then in the output, there is a selection button of SQL which will show the sql code.

Upvotes: 3

Related Questions