ADO.NET Demo Application - Complete Explanation

This is a comprehensive C# console application demonstrating CRUD operations using ADO.NET with SQL Server LocalDB, implementing the Data Access Layer (DAL) pattern with event-driven logging.

Architecture Overview

The application follows a layered architecture:


Component 1: POCO (Plain Old CLR Object) - Emp Class

namespace _21DemoADO.POCO
{
    public class Emp
    {
        public int No { get; set; }
        public string Name { get; set; }
        public string Address { get; set; }

        public override string ToString()
        {
            return string.Format("{0} | {1} | {2}", No, Name, Address);
        }
    }
}

Purpose: Represents the Employee entity


Component 2: FileLogger Class (Singleton Pattern)

namespace _21DemoADO.Loggers
{
    public class FileLogger
    {
        private static FileLogger _logger = new FileLogger();

        private FileLogger() { }  // Private constructor prevents instantiation

        public static FileLogger CurrentLogger
        {
            get { return _logger; }
        }

        public void Log(string message)
        {
            string path = "D:\\\\KaradDotNetDemos\\\\Data\\\\DBLog.txt";
            FileStream fs = null;

            if (File.Exists(path))
            {
                fs = new FileStream(path, FileMode.Append, FileAccess.Write);
            }
            else
            {
                fs = new FileStream(path, FileMode.Create, FileAccess.Write);
            }

            StreamWriter pen = new StreamWriter(fs);
            pen.WriteLine("Logged at " + DateTime.Now.ToString() + " - " + message);
            pen.Close();
            fs.Close();
        }
    }
}

Key Features: