473,750 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use repository pattern in Asp.net mvc?

83 New Member
How to use repository pattern in Asp.net mvc?
Oct 28 '20 #1
2 3531
SwissProgrammer
220 New Member
There is a convoluted article about that [here].

Please be more specific in your question please.

If you cannot be specific in detail, then tell us what you are trying to do and give us some of your thoughts on the difficulties that you are encountering.

Thank you.
Oct 29 '20 #2
Frinavale
9,735 Recognized Expert Moderator Expert
The idea behind this pattern is really to create an abstract layer between your classes and their data-store (the place(s) where their data is persisted).

Essentially, your class needs to be able to persist data in a repository somewhere...may be it's stored in a SQL database, or CSV file, or XML file...or maybe the data is stored in multiple places and needs to be aggregated together for your class's repository.

The details around actually maintaining that repository of data should not be the responsible of your Models/Entity/Base-Business-Layer-Class. The reasoning behind this is because once you start bleeding repository storage specifics into your base-classes, you cross layers and create a binding that can lead to problems in testing and/or force your class to be designed around how it's data is stored (which is not desirable).

Instead, you create an abstract interface that provides methods to server as the repository. This interface is defined in your application's base business logic layer but the implementation of the interface is done in your data access layer. This means that your business logic layer can implement the necessary methods/functions to carry out what it requires to work, but leaves the actual database work to the data access layer.

The implementation of the interface in the data access layer will take care of the specifics required for the repository. It's the implementation of the interface that does the work of getting/storing the data (which may be collected from multiple places, like your own database, an API call to a web service, and/or an external database from another system).

The benefit of abstracting the repository is that the implementation of the interface may be specific for testing purposes; wherein, the data returned by the implementation is known by the test code so that the business logic and classes can be tested for expected results. The two implementations (or more) can be swapped out depending on your needs.

The article linked in SwissProgrammer 's post should be helpful to you.
Nov 2 '20 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2132
by: games60 | last post by:
Hi, I have a xml file and i want to make the repository of it so that i can fire queries on it to extract the data i need from the XML file. Does anyone know how to make the XML repository. Thanks, Saurabh Aggrawal.
2
1240
by: E.T. Grey | last post by:
Hi, I am using CVS as my file repository for some VC projects. Does any one know which of the solution related files I need to store: i.e., do I need to store the files with these extensions: *.suo *.ncb
0
1529
by: yenlin.liu | last post by:
Who is the owner of the ebXML Registry Repository? Since The ebXML Registry Repository stores many business profiles and business scenarios. Companies can upload/download data from the ebXML RR. There should be an organization playing the leading role to establish or meintain the repository. Could anyone tell me who owns the repository and who has the responsibility to establish the repository? I found some ebXML Registry...
2
3305
by: Lars | last post by:
Hello, Anynoby knows a content repository similar to Content Repository for Java? I want to use a content repository without dependency of the storage system. I want to use file system or database to save our files. Can you help me? Thanks in adance
11
1783
by: HMS Surprise | last post by:
Greetings, Could someone point my muddled head at a/the python repository. I know that one exists but cannot find it again. In particular I am looking for a standalone search tool that given a path searches files for a text string. Thanks,
4
18273
by: rahatekarabhijeet | last post by:
Hi, I have seen that some modules which are available on CPAN are not listed in ActiveState repository. So those are not available to install by using ppm. I find out the way of adding adding repository in ppm given below, Way to add repository: To use these package repositories you start PPM and at the prompt type set repository NAME URL e.g: set repository JENDA http://Jenda.Krynicky.cz/perl
0
980
vikramadith
by: vikramadith | last post by:
I am new to patterns, so give me a hand here please. :D I am writing repository classes, and some of my GetSomething() methods will undoubtedly take a long time to complete. We will need to run them in a background thread so that the UI does not get jammed. Should I implement the event based asynchronous pattern in the repository classes themselves, or should I write something in the 'application layer' to handle all these slow methods in...
0
6280
by: gangadhar125 | last post by:
Hi I've created a repository named as allProj at server. allProj structure is as follows: allProj - Projects - projectA - projectB - projectC - projectD
0
9000
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8838
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9396
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8260
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6804
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.