Class DataTransferObject<T>
Abstract base class for Data Transfer Objects (DTOs) for managing object I/O operations.
Inheritance
Inherited Members
Namespace: Quantellia.WMServer.Base
Assembly: WMServer.dll
Syntax
public abstract class DataTransferObject<T> where T : IDbEntity, new()
Type Parameters
Name | Description |
---|---|
T |
Remarks
All concrete classes derived from DataTransferObject<T> must implement the following methods:
They may also override the method CreateModel(). By default, CreateModel() creates a new instance of the type, and calls UpdateModel() to populate it.
Constructors
DataTransferObject()
Default constructor that sets the ID to a new GUID.
Declaration
public DataTransferObject()
DataTransferObject(string)
Constructor that initializes the ID.
Declaration
public DataTransferObject(string id)
Parameters
Type | Name | Description |
---|---|---|
string | id |
DataTransferObject(T?)
Initialize object and set the reference to the ModelObject.
Declaration
public DataTransferObject(T? modelObj)
Parameters
Type | Name | Description |
---|---|---|
T | modelObj |
Properties
ID
Declaration
public string ID { get; protected set; }
Property Value
Type | Description |
---|---|
string |
ModelObject
Reference to the model object represented by this DTO.
Declaration
[NotMapped]
protected T ModelObject { get; set; }
Property Value
Type | Description |
---|---|
T |
Methods
CreateModel(DbContext, object[]?)
Create a new instance of the model type and updates its values based on the contents of this DTO.
Declaration
public virtual Task<T> CreateModel(DbContext context, object[]? data = null)
Parameters
Type | Name | Description |
---|---|---|
DbContext | context | |
object[] | data |
Returns
Type | Description |
---|---|
Task<T> |
FromModel()
Copy the data in this Data Transfer Object into the associated ModelObject
Declaration
public abstract void FromModel()
Remarks
Must be implemented by all concrete classes derived from DataTransferObject<T>
SetID(string)
Set the ID of this object.
Declaration
public void SetID(string id)
Parameters
Type | Name | Description |
---|---|---|
string | id |
UpdateModel(DbContext, object[]?)
Copy the data in this Data Transfer Object into the associated model object.
Declaration
public virtual Task<T> UpdateModel(DbContext context, object[]? data = null)
Parameters
Type | Name | Description |
---|---|---|
DbContext | context | |
object[] | data |
Returns
Type | Description |
---|---|
Task<T> |
Remarks
Must be implemented by all concrete classes derived from DataTransferObject<T>