Skip to content

oakcool/OakIdeas.GenericRepository

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenericRepository

OakIdeas.GenericRepository - Deploy

A very simple and generic implementation of the repository pattern for CRUD operations.

"Features"

  • Generic interface
  • EntityBase
  • Memory Repository (Dictionary based)

Usage

	public class Customer : EntityBase
	{
		public string Name { get; set; }
	}

	class Program
	{
		static void Main(string[] args)
		{   
		    // Create an instance of repositoy for Customers
		    var CustomerManager = new MemoryDataManager<Customer>();         

		    // Create (C)
		    var MyCustomer = CustomerManager.Insert(new Customer() { Name = name }).Result;

		    MyCustomer = null;

		    // Retrieve (R)
		    MyCustomer = CustomerManager.Get(x => x.Name == name).Result.FirstOrDefault();

		    // Update (U)
		    MyCustomer.Name = "Name Changed";
		    MyCustomer = CustomerManager.Update(MyCustomer).Result;

		    // Delete (D)
		    var deleted = CustomerManager.Delete(MyCustomer).Result;

		}
    	}

About

A generic repository

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages