Unit of Work DataPortal_Fetch

Unit of Work DataPortal_Fetch

Old forum URL: forums.lhotka.net/forums/t/11743.aspx


tiago posted on Monday, December 10, 2012

Hi Rocky,

On ProjectGetter.cs file of ProjectTracker sample, is there a reason why

    private void DataPortal_Fetch(Criteria criteria)

    {

      if (criteria.ProjectId == -1)

        Project = ProjectEdit.NewProject();

      else

        Project = ProjectEdit.GetProject(criteria.ProjectId);

      if (criteria.GetRoles)

        RoleList = RoleList.GetList();

    }

 

can't call the DataPortal methods directly and read like this

    private void DataPortal_Fetch(Criteria criteria)

    {

      if (criteria.ProjectId == -1)

        Project = DataPortal.Create<ProjectEdit>();

      else

        Project = DataPortal.Fetch<ProjectEdit>(criteria.ProjectId);

      if (criteria.GetRoles)

        RoleList = DataPortal.Fetch<RoleList>();

    }

Why do I ask this question?

Suppose you have a CriteriaBase criteria with several properties. In this case, I would receive this criteria as a parameter of this DataPortal_Fetch and re-send it directly to the respective DataPortal.

Otherwise I must have a ProjectEdit.GetProject factory method that accepts the referred CriteriaBase criteria as parameter, just to call DataPortal.Fetch<ProjectEdit> relaying the same parameter.

 

 

 

tiago replied on Monday, December 10, 2012

This is for consistency sake. Creator and Getter Unit of Work are ReadOnly objects. This is ok for Getter UoW but Creator UoW can't use DataPortal.Create. So the same pattern is used all around.

Copyright (c) Marimer LLC