Is CQRS alternative to CRUD?

5.1k views Asked by At

What is different between CQRS and CRUD and can I use the UnitOfWork and Repository patterns in both cases ?

If I have a complicated relationship between the entites which one you are recommending me and why ?

CQRS pattern : http://martinfowler.com/bliki/CQRS.html
CRUD : http://en.wikipedia.org/wiki/Create,_read,_update_and_delete

Any help will be greatly appreciated.

2

There are 2 answers

0
AudioBubble On BEST ANSWER

CQRS is usually used for complex application projects. DDD is also used for complex application projects and seems to be associated with CQRS. DDD attempts to deal with the complexity of the behaviour. CRUD systems have little or no behaviour. A system with little or no behaviour doesn't really have a complex event structure, so it's hard to say how much benefit you get from CQRS.

0
Rafał Ryszkowski On

CRUD - you perform reading and writing operations on one object.

CQRS - you split reading and writing operations into two separate objects. You can simplify it, and implement it as two separate interfaces on one object: one for reading, and one for writing. Then you can instantiate objects depending on what do you need it for. Or you can move it even further, and use separate databases for reading and writing.

For most cases CRUD is the answer, but CQRS can be applicable in some complex scenarios.

If you are using Entity Framework, you shouldn't use Unit of Work and Repository, because it's natively implemented by EF.

In CRUD, using Unit of Work and Repository is normal. For CQRS - I have no knowledge.