Thursday, August 10, 2017

How to view the SQL generated query by the Entity Framework

If we want to write log file of Entity Framework query in EF 6 we can follow this step

Step 1: Open EDMX cs file and copy the code:

  protected override void OnModelCreating(DbModelBuilder modelBuilder)  
       Database.Log = (query) => Debug.Write(query);  

Step 2 : write log on your Entity Framework query

  refauthrequests refauthEntity = EM_Refauthrequests.ConvertToEntity(vsspoAuditModel);  
       _db.Database.Log = queryLog =>  
         Debug.Print(queryLog); // Debug.Print will show the output on visual studio output window You can write log using queryLog value  

If you set debugger you will see the output window

C# print file on LAN Printer

If you want to print any file on network printer then you can try with this code block // Change Default Printer System.Ma...