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

34
Not just SQL… Serhiy Kalinets Rails Reactor [email protected] @skalinets @skalinets 1

Upload: fwdays

Post on 11-Jan-2017

241 views

Category:

Technology


2 download

TRANSCRIPT

@skalinets 1

Not just SQL…

Serhiy KalinetsRails Reactor

[email protected]@skalinets

@skalinets 2

About Me16 year in the business

In .NET since 2005

Love to code

@skalinets 3

@skalinets 4

.NETASP.NET

SQL ServerEntity Framework

@skalinets 5

What do all some .NET developers think about

EF?

@skalinets 6

@skalinets 7

Why PainToo much configuration

Leaking abstractions

Object model does not fit business model

Things become complicated very fast

@skalinets 8

@skalinets 9

But we know SQL!And ORMs treat a custom SQL an

“advanced” feature

@skalinets 10

Micro ORMs: the best from both worldsHandcraft SQL for queries

Handles mapping for you

Require less code (and provide less functionality)

@skalinets 11

Dapper By Stack exchange

Is very fast

Works with POCO and dynamics

@skalinets 12

PetaPocoFast like Dapper

Works with strictly undecorated POCOs, or attributed almost-POCOs

Built-in paging

SqlBuilder helps create SQL

@skalinets 13

Get datavar article1 = db.Single<Article>(123);

var article2 = db.Single<Article>("WHERE ArticleKey = @0", "ART-

123");

@skalinets 14

Modify datavar a = new article();a.title = "My new article";...db.Insert(a);

// Update ita.content = "Blah blah";db.Update(a);

// Delete itdb.Delete(a);

@skalinets 15

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 16

Simple Data Fun project of @markrendle

Seems to be dead

But still is fun

@skalinets 17

Simple Data

return Database.Open().Users.FindAllByEmail(email).FirstOrDefault();

@skalinets 18

Problems with SQLIt’s kind of old school

Object relational impedance mismatch

Poor scaling out

Schema first

@skalinets 19

NoSQLLot of options

NoSQL == no schema-first

Easy scale / deployment

Something new to give a try…

@skalinets 20

NoSQL typesDocument

Key-value storage

Column Family

Graph

http://nosql-database.org/ lists over 255 DBs

@skalinets 21

NoSQL: consNew kid on the block

Almost no analytics

And a lot of others…

@skalinets 22

But still…Most approaches store only the current view

Changing things retrospectively == PAIN

@skalinets 23

Event sourcing to rescue!

@skalinets 24

ES ConceptsEvent 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 25

How it worksChanges in domain trigger events

Entities (aggregates) accept events to update it’s state

Views (projections) accept events to get updated as well

@skalinets 26

Event sourcing

https://msdn.microsoft.com/en-us/library/dn589792.aspx

@skalinets 27

ES plays nice with CQRS

@skalinets 28

BenefitsSimple storage for events

Endless choices for projections

Projections can be changed at any time

Maximum data is stored compared to other models

@skalinets 29

d60 CirqusSimple but powerful event sourcing + CQRS kit

Fluent configuration

Support for multiple storages (MS SQL, Azure Service Bus, Entity Framework)

@skalinets 30

Cirqus FocusRaw performance Polished APIs and general usefulness=========================(+)=============

Complex event processing Domain-model-centric event processing==========================(+)============

.NET-centric Interoperable==========(+)============================

@skalinets 31

NEventStoreStorage agnostic event store

Focus on DDD / CQRS applications

@skalinets 32

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 33

And the most important

Don’t try it on work!