diff --git a/RepositoryPattern.sln b/RepositoryPattern.sln
new file mode 100644
index 0000000..a553a51
--- /dev/null
+++ b/RepositoryPattern.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30804.86
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RepositoryPattern", "RepositoryPattern\RepositoryPattern.csproj", "{A239AA80-AFE3-4B4B-AC60-C2EF697130C7}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {A239AA80-AFE3-4B4B-AC60-C2EF697130C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A239AA80-AFE3-4B4B-AC60-C2EF697130C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A239AA80-AFE3-4B4B-AC60-C2EF697130C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A239AA80-AFE3-4B4B-AC60-C2EF697130C7}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {DEA63362-5E0F-44C4-AF18-358A682FA93B}
+ EndGlobalSection
+EndGlobal
diff --git a/RepositoryPattern/App.config b/RepositoryPattern/App.config
new file mode 100644
index 0000000..fd3821e
--- /dev/null
+++ b/RepositoryPattern/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RepositoryPattern/AppConnection.cs b/RepositoryPattern/AppConnection.cs
new file mode 100644
index 0000000..8bd408c
--- /dev/null
+++ b/RepositoryPattern/AppConnection.cs
@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RepositoryPattern
+{
+ public class AppConnection
+ {
+ public static string ConnectionString => ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
+ }
+}
diff --git a/RepositoryPattern/Form1.Designer.cs b/RepositoryPattern/Form1.Designer.cs
new file mode 100644
index 0000000..562b342
--- /dev/null
+++ b/RepositoryPattern/Form1.Designer.cs
@@ -0,0 +1,79 @@
+
+namespace RepositoryPattern
+{
+ partial class Form1
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.lblTotalRecords = new System.Windows.Forms.Label();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // dataGridView
+ //
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Location = new System.Drawing.Point(12, 12);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(776, 393);
+ this.dataGridView.TabIndex = 0;
+ //
+ // lblTotalRecords
+ //
+ this.lblTotalRecords.AutoSize = true;
+ this.lblTotalRecords.Location = new System.Drawing.Point(12, 408);
+ this.lblTotalRecords.Name = "lblTotalRecords";
+ this.lblTotalRecords.Size = new System.Drawing.Size(98, 15);
+ this.lblTotalRecords.TabIndex = 2;
+ this.lblTotalRecords.Text = "Total Records: ???";
+ //
+ // Form1
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.lblTotalRecords);
+ this.Controls.Add(this.dataGridView);
+ this.MinimizeBox = false;
+ this.Name = "Form1";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "Repository Pattern";
+ this.Load += new System.EventHandler(this.Form1_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView dataGridView;
+ private System.Windows.Forms.Label lblTotalRecords;
+ }
+}
+
diff --git a/RepositoryPattern/Form1.cs b/RepositoryPattern/Form1.cs
new file mode 100644
index 0000000..d4e963e
--- /dev/null
+++ b/RepositoryPattern/Form1.cs
@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace RepositoryPattern
+{
+ public partial class Form1 : Form
+ {
+ IProductRepository _productRepository;
+ public Form1(IProductRepository productRepository)
+ {
+ InitializeComponent();
+ _productRepository = productRepository;
+ }
+
+ private void Form1_Load(object sender, EventArgs e)
+ {
+ dataGridView.DataSource = _productRepository.GetProducts();
+ lblTotalRecords.Text = $"Total records: {dataGridView.RowCount}";
+ }
+ }
+}
diff --git a/RepositoryPattern/Form1.resx b/RepositoryPattern/Form1.resx
new file mode 100644
index 0000000..f298a7b
--- /dev/null
+++ b/RepositoryPattern/Form1.resx
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/RepositoryPattern/IProductRepository.cs b/RepositoryPattern/IProductRepository.cs
new file mode 100644
index 0000000..17bf714
--- /dev/null
+++ b/RepositoryPattern/IProductRepository.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RepositoryPattern
+{
+ public interface IProductRepository
+ {
+ IEnumerable GetProducts();
+ bool Insert(Product product);
+ bool Update(Product product);
+ bool Delete(string productId);
+ }
+}
diff --git a/RepositoryPattern/Product.cs b/RepositoryPattern/Product.cs
new file mode 100644
index 0000000..bc4f0c1
--- /dev/null
+++ b/RepositoryPattern/Product.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace RepositoryPattern
+{
+ public class Product
+ {
+ public string ProductId { get; set; }
+ public string ProductName { get; set; }
+ public decimal UnitPrice { get; set; }
+ public string Barcode { get; set; }
+ public int UnitsInStock { get; set; }
+ }
+}
diff --git a/RepositoryPattern/ProductRepository.cs b/RepositoryPattern/ProductRepository.cs
new file mode 100644
index 0000000..42b8248
--- /dev/null
+++ b/RepositoryPattern/ProductRepository.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Dapper;
+
+namespace RepositoryPattern
+{
+ public class ProductRepository : IProductRepository
+ {
+ public bool Delete(string productId)
+ {
+ throw new NotImplementedException();
+ }
+
+ public IEnumerable GetProducts()
+ {
+ using IDbConnection db = new SqlConnection(AppConnection.ConnectionString);
+ if (db.State == ConnectionState.Closed)
+ db.Open();
+ return db.Query("select ProductId, ProductName, UnitPrice, UnitsInStock ,RIGHT('00000' + cast(ProductId as varchar) , 5) As Barcode from Products", commandType: CommandType.Text);
+ }
+
+ public bool Insert(Product product)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool Update(Product product)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/RepositoryPattern/Program.cs b/RepositoryPattern/Program.cs
new file mode 100644
index 0000000..05e077f
--- /dev/null
+++ b/RepositoryPattern/Program.cs
@@ -0,0 +1,37 @@
+using Autofac;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace RepositoryPattern
+{
+ static class Program
+ {
+ public static IContainer Container;
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ static void Main()
+ {
+ Application.SetHighDpiMode(HighDpiMode.SystemAware);
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+ Container = Configure();
+ Application.Run(new Form1(Container.Resolve()));
+ }
+ ///
+ /// Setting dependency injection
+ ///
+ ///
+ static IContainer Configure()
+ {
+ var builder = new ContainerBuilder();
+ builder.RegisterType().As();
+ builder.RegisterType();
+ return builder.Build();
+ }
+ }
+}
diff --git a/RepositoryPattern/RepositoryPattern.csproj b/RepositoryPattern/RepositoryPattern.csproj
new file mode 100644
index 0000000..dff69ee
--- /dev/null
+++ b/RepositoryPattern/RepositoryPattern.csproj
@@ -0,0 +1,15 @@
+
+
+
+ WinExe
+ netcoreapp3.1
+ true
+
+
+
+
+
+
+
+
+
\ No newline at end of file