Giter Site home page Giter Site logo

dotnet-examples's Introduction

ENTITY FRAMEWORK

Repository Pattern:

  • Mediates between the domain and data mapping layers, acting like an in-memory collection of domain objects.
Benefits
  • Minimizes duplicate query logic
Example:

Imagine in a few different places in our application we need to get the first five top selling courses in a given category without the repository pattern will end up duplicating this query logic over and over in different places in situations like the following.

var topSellingCourses = context.Courses
.Where(c => c.IsPublic && c.IsApproved)
.OrderByDescending(c => c.Sales)
.Take(10);

In previous situations, We can encapsulate this logic in a repository and simply call a method like get top selling courses.

var courses = repository.GetTopSellingCourses(category, count);
  • Decouples your application from persistence frameworks
  • Promotes testability
  • A repository should not have the semantics of your database.

How we are going to save the changes?

Unit of Work pattern:

  • Maintain a list of objects affected by a business transaction and coordinates the writting out of changes.
Clean architecture

An architecture should be independent of frameworks.

dotnet-examples's People

Contributors

franco148 avatar dependabot[bot] avatar franco-avantica avatar

Watchers

James Cloos avatar  avatar  avatar

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.