✔️Entity Classes

Definition

In JFW, each Entity Class (named as C + Entity name, such as CUser) is a class that represents a data table. It has properties and methods that can be used to manipulate the data.

Get Entity List

To retrieve all entities from the database, you can use the static method List. If the method supports it, you can filter the entity list by passing some parameters to the method.

List<CUser> users = CUser.List();

Add an Entity

To add a new single Entity, create a new Entity object and then call the Add method to insert the object into the database.

CUser aNewUser = new CUser
{
    BrandId = 1,
    Username = "admin"
    Password = "@Abc123456",
    UserType = (short)UserType.EndUser,
    Status = 1
};

CUser aNewCreatedUser = CUser.Add(aNewUser); // After we add the object to database, we will process data and return a new created object with updated fields.

Get an Entity

A static method called Get can retrieve an Entity if you pass its ID as an argument. Alternatively, you can use other static methods that start with GetBy... to get an Entity based on different criteria.

CUser aUser = CUser.Get(1); // If there is no Entity with ID = 1, aUser will be null.

Update an Entity

To modify the Entity in the database, you can use the Update method.

Delete an Entity

To delete an Entity, you need to pass its ID to the Delete method. Some methods can also delete an Entity based on other fields.

Entity Class List

chevron-rightBrandhashtag

Last updated