Tuesday, October 31, 2023

Logical SQL query processing order of query clauses



1 FROM (Joins if available)
2 WHERE 
3 GROUP BY 
4 HAVING 
5 SELECT
    5.1 SELECT list
    5.2 DISTINCT
6 ORDER BY  

7 TOP / OFFSET-FETCH 

Thursday, March 16, 2023

Sample Code for Get appSetting config value in .Net Core application

 I have created Sample class to the Key Values from application (appSettings.json). for that i have initialise the Configuration instance at Constructor level. Later on consumed same instance to get the Key Value.

Sample Code is Below

Calling from application

string Conn = ConfigurationExtension.GetConfigKeyValue("ConnectionStrings:DBConnection").ToString();

Base Code 

    public class ConfigurationExtension

    {

        IConfiguration configuration;

        public ConfigurationExtension()

        {

            var builder = new ConfigurationBuilder()

                .AddJsonFile("appSettings.json");

            configuration = builder.Build();

        }


        /// <summary>

        /// Get appSettings json key value ex Key: "ConnectionStrings:DBConnection"

        /// </summary>

        /// <param name="Key"></param>

        /// <returns></returns>

        public static string GetConfigKeyValue(string Key) {

            ConfigurationExtension obj = new ConfigurationExtension();            

            string con = obj.configuration[Key].ToString();

            return con;

        }

    }


Friday, January 27, 2023

Sample

using Syncfusion.XlsIO;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;


using Syncfusion.DocIO;

using Syncfusion.DocIO.DLS;


private void SyncFileDocDemo() 

        {

            //Creates an empty Word document instance

            WordDocument document = new WordDocument();

            //Loads or opens an existing word document through Open method of WordDocument class

            document.Open(Server.MapPath(@"SpreadSheet.docx"));


            document.Save(Server.MapPath("Result\\SpreadSheet.odt"), FormatType.Odt);

        }


        private void SyncFuExcelData() 

        {

            //Step 1 : Instantiate the spreadsheet creation engine.

            ExcelEngine excelEngine = new ExcelEngine();

            //Step 2 : Instantiate the excel application object.

            IApplication application = excelEngine.Excel;


            //A new workbook is created.[Equivalent to creating a new workbook in Microsoft Excel]

            //The new workbook will have 12 worksheets

            IWorkbook workbook = application.Workbooks.Open(Server.MapPath(@"SpreadSheet.xls"));


            string SaveOption = "Xls";

            try

            {

                //Saving the workbook to disk.

                if (SaveOption == "Xls")

                {

                    //Save as .xls format

                    workbook.SaveAs(Server.MapPath("Result\\SpreadSheet.ods"), HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel97);

                }

                //Save as .xlsx format

                else

                {

                    workbook.Version = ExcelVersion.Excel2016;

                    workbook.SaveAs("SpreadSheet.xlsx", HttpContext.ApplicationInstance.Response, ExcelDownloadType.PromptDialog, ExcelHttpContentType.Excel2016);

                }

            }

            catch (Exception)

            {

            }

        }