What is the use of a persistence layer in any application?

前端 未结 5 1723
猫巷女王i
猫巷女王i 2020-12-12 22:42

I have to create an application in which I am asked to create an persistence layer in the application. The application is in .net. I have created a business layer and a pres

5条回答
  •  时光取名叫无心
    2020-12-12 23:13

    In very simple terms a persistence layer is a way to SAVE and RETRIEVE items that your application uses.

    A simple example is you have a class that represents a person (name, age and gender). While your application is running this is held in memory. But, say you want that information available if you close and open your application again. Well, you need some way to SAVE that person and then later on RETRIEVE it again. This is where a persistence layer comes in and will write your person somewhere "permanent".

    That could be a database, a flat file, registry depending on the life-time and requirements etc.

    In your persistence layers you will perform CRUD (Create, Read, Update, Delete) operations. Often against a database so you would Create a new person (Fred Bloggs). Say they change their name another user of your system might Read the record and change to Fred Miggins and Update the database. That customer then leaves the country so you Delete them.

提交回复
热议问题