ManagerBase class

Provides a useful base class of methods for accessing the various functions of ObjectFactory. Inherit this class or create your own class that implements IManager for compatibility with the ManagerHost class.

Namespace: ReFlex.Data namespace
Assembly: ReFlex.Data.dll

Syntax

public abstract class ManagerBase<T> : IDisposable, IManager

Constructors

// T is the type of data objects that will be persisted and retrieved
ManagerBase<T>();

Remarks

The abstract ManagerBase class provides a number of overloaded methods for retrieving and persisting your object to and from your database(s). This is particularly useful when you want to create a manager for your data objects that either does not provide restrictions on retrieval and persistance operations, or has minimal restrictions implemented through overriding the ManagerBase methods.

If you do want to restrict how the objects are persisted and/or retrieved, you can either inherit ManagerBase and override the methods you wish to add custom logic to, or implement IManager on your manager class and create your custom methods as desired.

Examples

// simple contact class representing tblContact in database
public class Contact
{
    public int ContactID;

    [RelationalMemberInfo(Length = 50)]
    public string FirstName;
   
    [RelationalMemberInfo(Length = 50)]
    public string LastName;

    [RelationalMemberInfo(IsIntZeroConvertedToNull = true)]
    public int CompanyID;

    public DateTime CreatedDate;
}

// contact manager class inheriting ManagerBase and
// overriding SaveItem for some extra processing
public class ContactManager : ReFlex.Data.ManagerBase<Contact>
{
    public override int SaveItem(Contact obj)
    {
        if (obj.ContactID == 0)
            obj.CreatedDate = DateTime.Now;
       
        return base.SaveItem(obj);
    }
}