support

Dec 18, 2014 at 9:55 PM
Do you develop and support again this lib because I project to use this or https://genericunitofworkandrepositories.codeplex.com/
Coordinator
Dec 19, 2014 at 2:32 PM
Edited Dec 19, 2014 at 4:43 PM
Yes, this is still fully supported and updated. My advice would be to give both a go and see what's best for you.

To get you started using this project simply add the 'NRepository.EntityFramework' and / or 'NRepository.MongoDb' NUGet package to your project and try out some of the examples found in the Quick start guide at https://nrepository.codeplex.com/.
Dec 20, 2014 at 8:01 PM
Edited Dec 21, 2014 at 7:44 PM
thanks

Do you plan to make more exhaustive documentation ? And the last question ;) Do you have a system to make a transaction and state of object as the pattern of unit of work ?
Coordinator
Dec 22, 2014 at 7:10 PM
Edited Dec 22, 2014 at 7:11 PM
I'll be revamping the documentation over the holidays. Going to try and get at least one video up and running too.

As for the unit of work pattern all you have to do is instantiate a repository and that's what you get - a unit of work object. Simply make any changes to your entities and save and if there's any problems it will automatically rollback all the changes for you. (Actually EF does all the hard work as NRepository.EntityFramework is an abstraction over EF and EF is the UOW) See example below:
            using(var uow = new EntityFrameworkRepository(new MyDbContext()))
            {
               var person = uow.GetEntity<Person>(p => p.Id = 1) ;
               person.Name = "Bob";
               uow.Modify(person);

               var unwantedPerson = uow.GetEntity<Person>(p => p.Id = 2) ;
               uow.Delete(unwantedPerson);

                // Can also add using 
                // uow.Add
                // or use the extension method 
                // uow.UpdateEntityState(person, EntityState.Detached);

                // Then save you changes. EF will ensure the changes will be transactional
                uow.Save();
            }
Dec 22, 2014 at 8:22 PM
ok great
I suppose is work fine with mongoDB too ?
Coordinator
Dec 22, 2014 at 10:08 PM
Edited Dec 27, 2014 at 5:33 PM
Yes. Using the Nuget package Nrepository.MongoDb you can use the following code:
            using (var uow= new MongoDbUnitOfWorkRepository(CreateMongoDatabase()))
            {
                        var person = uow.GetEntity<PersonDocument>(p => p.Id = 1) ;
                        person.Name = "Bob";
                        uow.Modify(person);

                        var person2 = uow.GetEntity<PersonDocument>(p => p.Id = 2) ;
                        person2 .Name = "Bob2";
                        uow.Modify(person2 );

                        uow.Save();
            }
Be careful though, MongoDb though doesn't support 'transactions' across documents so the UOW pattern will only apply to individual documents. The unit of work repository above is there purely to group saves of multiple documents. On the MongoDb web site there is a way to simulate 2 a phase commit so I'm going to have a look at this and see if it can be incorporated into the next update of the MongoDb NuGet package.