Skip to main content
edited body
Source Link
Ewan
  • 79.8k
  • 5
  • 83
  • 179

Your questions are confusing. perhaps because your example is so lightweight

IItemRepo
{
   Item GetItem(id)
   List<Item> GetItemsByName(name)
   List<Item> GetItemsBySpecifedFiltersAndConditions(colour, weight, whatever)
   ...
}

Api
{
   start()
   {
      //repo is initialised in startup for DI where required
      diContainer.Register<IItemRepo>(new ItemRepo(dbconnection))
   }
}

ItemController
{
   GetItem(id)
   {
       //api controllers / application layer will know about the underlying data layer
       //api layer uses repo by reference passed in from di
       return _repo.GetItem(id);
   }

   ...
}

SomeDomainApplications
{
    ShipItems(itemIdsToShip)
    {
       foreach(id in itemIdsToShip)
       var i = apiClient.GetItem(id) //item retrieved from API. Item is an AGAR domain object, its fine to pass domain objects around you dont need dtos and the repo is not passed around
       if(somelogic)
           ShippingDomainLogic.Ship(i) //business log shares item object but doesnt see repo

       apiClient.DeleteItem(i);
    }

}

Your questions are confusing. perhaps because your example is so lightweight

IItemRepo
{
   Item GetItem(id)
   List<Item> GetItemsByName(name)
   List<Item> GetItemsBySpecifedFiltersAndConditions(colour, weight, whatever)
   ...
}

Api
{
   start()
   {
      //repo is initialised in startup for DI where required
      diContainer.Register<IItemRepo>(new ItemRepo(dbconnection))
   }
}

ItemController
{
   GetItem(id)
   {
       //api controllers / application layer will know about the underlying data layer
       //api layer uses repo by reference passed in from di
       return _repo.GetItem(id);
   }

   ...
}

SomeDomainApplications
{
    ShipItems(itemIdsToShip)
    {
       foreach(id in itemIdsToShip)
       var i = apiClient.GetItem(id) //item retrieved from API. Item is an AG domain object, its fine to pass domain objects around you dont need dtos and the repo is not passed around
       if(somelogic)
           ShippingDomainLogic.Ship(i) //business log shares item object but doesnt see repo

       apiClient.DeleteItem(i);
    }

}

Your questions are confusing. perhaps because your example is so lightweight

IItemRepo
{
   Item GetItem(id)
   List<Item> GetItemsByName(name)
   List<Item> GetItemsBySpecifedFiltersAndConditions(colour, weight, whatever)
   ...
}

Api
{
   start()
   {
      //repo is initialised in startup for DI where required
      diContainer.Register<IItemRepo>(new ItemRepo(dbconnection))
   }
}

ItemController
{
   GetItem(id)
   {
       //api controllers / application layer will know about the underlying data layer
       //api layer uses repo by reference passed in from di
       return _repo.GetItem(id);
   }

   ...
}

SomeDomainApplications
{
    ShipItems(itemIdsToShip)
    {
       foreach(id in itemIdsToShip)
       var i = apiClient.GetItem(id) //item retrieved from API. Item is an AR domain object, its fine to pass domain objects around you dont need dtos and the repo is not passed around
       if(somelogic)
           ShippingDomainLogic.Ship(i) //business log shares item object but doesnt see repo

       apiClient.DeleteItem(i);
    }

}
Source Link
Ewan
  • 79.8k
  • 5
  • 83
  • 179

Your questions are confusing. perhaps because your example is so lightweight

IItemRepo
{
   Item GetItem(id)
   List<Item> GetItemsByName(name)
   List<Item> GetItemsBySpecifedFiltersAndConditions(colour, weight, whatever)
   ...
}

Api
{
   start()
   {
      //repo is initialised in startup for DI where required
      diContainer.Register<IItemRepo>(new ItemRepo(dbconnection))
   }
}

ItemController
{
   GetItem(id)
   {
       //api controllers / application layer will know about the underlying data layer
       //api layer uses repo by reference passed in from di
       return _repo.GetItem(id);
   }

   ...
}

SomeDomainApplications
{
    ShipItems(itemIdsToShip)
    {
       foreach(id in itemIdsToShip)
       var i = apiClient.GetItem(id) //item retrieved from API. Item is an AG domain object, its fine to pass domain objects around you dont need dtos and the repo is not passed around
       if(somelogic)
           ShippingDomainLogic.Ship(i) //business log shares item object but doesnt see repo

       apiClient.DeleteItem(i);
    }

}