Not just SQL…
Serhiy Kalinets
Rails Reactor
kalinets@gmail.com
@skalinets
@skalinets 1
About Me
16 year in the
business
In .NET since 2005
Love to code
@skalinets 2
@skalinets 3
.NET
ASP.NET
SQL Server
Entity Framework
@skalinets 4
What do all some .NET developers
think about
EF?
@skalinets 5
@skalinets 6
Why Pain
Too much configuration
Leaking abstractions
Object model does not fit business model
Things become complicated very fast
@skalinets 7
@skalinets 8
But we know SQL!
And ORMs treat a custom SQL an
“advanced” feature
@skalinets 9
Micro ORMs:
the best from both worlds
Handcraft SQL for queries
Handles mapping for you
Require less code (and provide less
functionality)
@skalinets 10
Dapper
By Stack exchange
Is very fast
Works with POCO and dynamics
@skalinets 11
PetaPoco
Fast like Dapper
Works with strictly undecorated POCOs, or
attributed almost-POCOs
Built-in paging
SqlBuilder helps create SQL
@skalinets 12
Get data
var article1 = db.Single<Article>(123);
var article2 =
db.Single<Article>(
"WHERE ArticleKey = @0", "ART-123");
@skalinets 13
Modify data
var a = new article();
a.title = "My new article";
...
db.Insert(a);
// Update it
a.content = "Blah blah";
db.Update(a);
// Delete it
db.Delete(a); @skalinets 14
Or this way..
db.Delete<article>(
"WHERE article_id=@0",
123);
db.Update<article>(
"SET title=@0 WHERE article_id=@1",
"New Title",
123);
@skalinets 15
Simple Data
Fun project of @markrendle
Seems to be dead
But still is fun
@skalinets 16
Simple Data
return Database.Open()
.Users.FindAllByEmail(email)
.FirstOrDefault();
@skalinets 17
Problems with SQL
It’s kind of old school
Object relational impedance mismatch
Poor scaling out
Schema first
@skalinets 18
NoSQL
Lot of options
NoSQL == no schema-first
Easy scale / deployment
Something new to give a try…
@skalinets 19
NoSQL types
Document
Key-value storage
Column Family
Graph
http://nosql-database.org/ lists over 255 DBs
@skalinets 20
NoSQL: cons
New kid on the block
Almost no analytics
And a lot of others…
@skalinets 21
But still…
Most approaches store only the current view
Changing things retrospectively == PAIN
@skalinets 22
Event sourcing to rescue!
@skalinets 23
ES Concepts
Event is something that has happened
Event can always be applied (no validation
needed)
Events are persisted in event store
Events are available via streams
@skalinets 24
How it works
Changes in domain trigger events
Entities (aggregates) accept events to update
it’s state
Views (projections) accept events to get
updated as well
@skalinets 25
Event sourcing
https://msdn.microsoft.com/en-us/library/dn589792.aspx
@skalinets 26
ES plays nice with CQRS
@skalinets 27
Benefits
Simple storage for events
Endless choices for projections
Projections can be changed at any time
Maximum data is stored compared to other
models
@skalinets 28
d60 Cirqus
Simple but powerful event sourcing + CQRS kit
Fluent configuration
Support for multiple storages (MS SQL, Azure
Service Bus, Entity Framework)
@skalinets 29
Cirqus Focus
Raw performance Polished APIs and general
usefulness
=========================(+)=============
Complex event processing Domain-model-centric
event processing
==========================(+)============
.NET-centric Interoperable
==========(+)============================
@skalinets 30
NEventStore
Storage agnostic event store
Focus on DDD / CQRS applications
@skalinets 31
But…
SQL (and MS SQL) are still in the game
There are more than one approaches to SQL
handling
There are more than one approaches to data
storage
@skalinets 32
And the most important
Don’t try it on work!
@skalinets 33
Resources
http://www.toptensoftware.com/petapoco/
https://github.com/StackExchange/dapper-dot-net
https://msdn.microsoft.com/en-
us/library/dn589792.aspx (ES)
http://neventstore.org
https://github.com/d60/Cirqus
@skalinets 34

Сергей Калинец "Не SQL-ом единым..."