GithubHelp home page GithubHelp logo

ajeetx / generic.repository.entityframework Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 2.0 792 KB

A light, simple EntityFramework wrapper

License: MIT License

C# 100.00%
entityframework orm dbcontext code-first sqlserver dotnet csharp database vbnet vb-net

generic.repository.entityframework's Introduction

Generic.Repository.EntityFramework GitHub release Maintenance

GitHub Release Date Website azy MyGet Build Status Build Status
.Net Framework GitHub language count GitHub top language GitHub repo size in bytes

Purpose of statement

In order to perform database CRUD operation from .net application, 
the wrapper makes it quite easy by following the below steps.

Steps to use the NuGet package

In VS2015 or above, Create .net application [.net4.6.1] to interact with Sql server database

  1. Search nuget package with name 'Generic.Repository.EntityFramework'.
  2. Download the NuGet through VS IDE to install in your project.
  3. Create your EntityFramework DataModel, then tweak the DataModel as below

IDbContext type is inherited from the installed NuGet package

using Generic.Repository.EntityFramework;       //add this reference
//DB is real data model created from database
public partial class DB : DbContext, IDbContext   
{ 
  public DB() : base("name=connectionstring"){} 
  IDbSet<T> IDbContext.Set<T>()
  {
  	return base.Set<T>();
  }
  public DbSet<Customer> Customers {get;set;}
  public int Save()
  {
  	return base.SaveChanges();
  }
  ....
}
  1. Now all set, please add the below lines from your consuming object/component
//add these 2 references
using Generic.Repository.EntityFramework;
using Unity;  

public class ConsumeService
{
     ...
    void ConsumeMethod()
    {           
           var container = UnityConfig.Container; //get the Unity container
             
           container.RegisterType<IDbContext, DB>(); // register your 'DataModel'
     
           var dbManager=container.Resolve<IDBManager>(); //get the db manager
     
	      //All wired up. DO YOUR CRUD OPERATION  & Customer is the table name in DB 
         
         var result=dbManager.GetRepository<Customer>().Get();  //GET	All
       
         //FIND by id, where id is the primary key
	     var result=dbManager.GetRepository<Customer>().Find(id); 

         // custObj is the Customer object
	     var result=dbManager.GetRepository<Customer>().Add(custObj); //ADD

	     var result=dbManager.GetRepository<Customer>().Update(custObj); // UPDATE

 	     var result=dbManager.GetRepository<Customer>().Delete(custObj); // DELETE
     }

Application list and details

App Name Type Comments
Generic.Repository.EntityFramework* Class Library EntityFramework wrapping business logic
Generic.Repository.EntityFramework.Test Test App unit tests
Generic.Repository.EntityFramework.ConsoleApp.Test Console Test the wrapping business logic

*nuget package "Generic.Repository.EntityFramework" is a wrapper around ORM EntityFramework


Support or Contact

Having any trouble? Check out our documentation or contact support and we’ll help you sort it out.

GitHub (Pre-)Release Date Github commits (since latest release) Downloads Downloads
HitCount GitHub contributors license

generic.repository.entityframework's People

Contributors

ajeetx avatar azeetkumar avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

vijaybandi bubdm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.