views:

175

answers:

1

I know it's fairly straight forward to create Repository for retreiving domain models without ORM (http://stackoverflow.com/questions/446629/repository-pattern-without-linq-or-other-orm). However, what about saving domain models and its internal object graph?

public class Car: IAggregateRoot, IEntity, ICar
{
  public IEnumerable<IWheel> Wheels {get; set;}
}

public class CarRepository
{
  public void Save(ICar car) 
  {
    // calls Dao
    // update/insert all wheels as required
    // update/insert car as required
  }
}

Here we need to take about change tracking etc. How does one go about to implement it?

For my specific implementation I'm treating Linq to Sql as Dao. Linq to sql does change tracking but the domain models that I created are not. They are straight POCO and not mapped directly by linq to sql. Everything is done by a custom DataMapper

public class CarDataMapper : IMapper<LinqData.Car, Domain.ICar>
{
  public ICar Map(LinqData.Car linqCar)
  {
    ICar = new Car () { Wheels = linqCar.Wheels.Select( w => new WheelDataMapper().Map(w));
  }
}

Is there any straight forward way to implement Repository to save object graph without exposing linqToSql or NHibernate to the domain layer? Or am I missing something here?

+1  A: 

I am too struggling to find out solution..

DDD without ORM, is it possible.. Look at http://solveme.wordpress.com/2009/11/11/ddd-without-any-orm-tool-is-it-possible/

SN