O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.
.NET Data Access Strategies for Couchbase and
Language Integrated Query
Using Couchbase with .NET
Martin Esmann
Developer ...
Who’s to blame?
2
Goal!
3
Learn how to access data in
Couchbase Server with the .NET SDK
With the main focus on N1QL
I’m assuming you know a...
Agenda
4
• Couchbase – Quick Overview
• Couchbase .NET SDK 2.X
• Basic Data Access Operations
• Views (…)
• N1QL – SQL lik...
Disclaimer
5
Details presented in this presentation
may change based on customer
feedback and other factors by the time
th...
Couchbase – Quick Overview
6
Couchbase – Quick Overview
7
A document store and key-value store
Lightning fast: built-in caching
Query with map-reduce a...
Views vs N1QL
8
Views are sill very relevant an in many cases the recommended approach to
data query.
Compared to Views, N...
Current demo setup
9
Developer Environment Setup - Overview
10
Application Server
Couchbase Cluster
(3 nodes, 8GB, 4 cores)
Demo PC with Visual...
Demo Setup - Overview
11
Couchbase Node
(1 node, 8GB, 4 cores)
Demo PC with Visual Studio
(Code runs from here)
Windows Az...
Couchbase .NET SDK
12
.NET SDK overview
13
Main purpose of any SDK is to make life easier for developers!
• Cluster
• Bucket
• ClientConfigurati...
Cluster Object
14
• Maintains references to all open buckets
• Should be a singleton (in most applications)
• Maintains th...
Bucket class
15
• “Super API” for all other APIs
• Memcached (K/V)
• Views
• N1QL
• Subscriber for config changes
• Serial...
ClientConfiguration Class
16
• Configures bootstrapping, connection pooling and general client
behavior
• Maps (“adapts”) ...
ClusterHelper
17
• Makes it “easy” to use the Cluster/Bucket
• Cluster is a singleton
• Buckets are multitons
• It will ma...
The IResult Interface
19
• As a rule the Bucket class doesn’t “throw” exceptions
• IResult is the primary interface for re...
.NET SDK Query options
21
• Key/value
• Views (we will not cover views in this talk)
• N1QL (pronounced nickel)
• SQL like...
Demo
Querying data with the .NET SDK and N1QL
Linq2Couchbase
The best from N1QL and LINQ
23
LINQ support for N1QL
24
Linq2Couchbase is a LINQ provider that wraps a subset of the available N1QL
queries to LINQ
• An ...
Demo
N1QL with LINQ
Best practices –
Application Architecture and Abstractions
Software design principles, maintainability and testable code
s...
Design decisions
27
• N1QL in the UI layer?
• Queries in the UI Layer?
• Hard vs. Loose coupling to Couchbase SDK?
• Testa...
The Repository Pattern
28
“Mediates between the domain and data mapping layers using a
collection-like interface for acces...
Demo
Repository pattern
29
Couchbase .NET SDK version NEXT
Knowledge about tomorrow can greatly help us plan today!
30
The Ubiquitous Repository
31
“Mediates between the domain and data mapping layers using a
collection-like interface for ac...
.NET SDK - Version Next
32
• async/await support
• Observable support
- Excepted ETA is April
• LINQ to N1QL support in SD...
Summary
33
Resources
34
• .NET SDK
https://github.com/couchbase/couchbase-net-client
• Linq2Couchbase
https://github.com/couchbaselab...
Key take-aways
35
• Couchbase supports advanced data query with N1QL
• LINQ support in the workings
• async/await + Observ...
Forums
forums.couchbase.com
36
Questions?
37
Thanks for listening!
Martin Esmann
Developer Advocate @ Couchbase
Twitter: martinesmann
martin@couchbase.com
38
Próximos SlideShares
Carregando em…5
×

Couchbase Live Europe 2015: .NET Data Access Strategies for Couchbase and Language Integrated Query

792 visualizações

Publicada em

Learn .NET access strategies and integrated query with Couchbase Server.

  • Seja o primeiro a comentar

Couchbase Live Europe 2015: .NET Data Access Strategies for Couchbase and Language Integrated Query

  1. 1. .NET Data Access Strategies for Couchbase and Language Integrated Query Using Couchbase with .NET Martin Esmann Developer Advocate twitter: martinesmann martin@couchbase.com
  2. 2. Who’s to blame? 2
  3. 3. Goal! 3 Learn how to access data in Couchbase Server with the .NET SDK With the main focus on N1QL I’m assuming you know a bit about N1QL already
  4. 4. Agenda 4 • Couchbase – Quick Overview • Couchbase .NET SDK 2.X • Basic Data Access Operations • Views (…) • N1QL – SQL like query for Couchbase • Linq2Couchbase • Best practices – Application Architecture and Abstractions • What’s coming next (async, await, observable, reactive)
  5. 5. Disclaimer 5 Details presented in this presentation may change based on customer feedback and other factors by the time the final version of the product is released.
  6. 6. Couchbase – Quick Overview 6
  7. 7. Couchbase – Quick Overview 7 A document store and key-value store Lightning fast: built-in caching Query with map-reduce and N1QL Scales massively Key benefit: it’s simple and fast. Challenges (before N1QL): Data query requires more work
  8. 8. Views vs N1QL 8 Views are sill very relevant an in many cases the recommended approach to data query. Compared to Views, N1QL is even more flexible in terms of search capability, but with this flexibility there is a potential tradeoff for performance (automatic indexes). In short, Views definitely have there place and so does N1QL it just depends on you specific needs.
  9. 9. Current demo setup 9
  10. 10. Developer Environment Setup - Overview 10 Application Server Couchbase Cluster (3 nodes, 8GB, 4 cores) Demo PC with Visual Studio (Code runs from here) Windows Azure Cloud Virtual Network (private)
  11. 11. Demo Setup - Overview 11 Couchbase Node (1 node, 8GB, 4 cores) Demo PC with Visual Studio (Code runs from here) Windows Azure Cloud N1QL DP 4 (Separate download) Virtual Network (private)
  12. 12. Couchbase .NET SDK 12
  13. 13. .NET SDK overview 13 Main purpose of any SDK is to make life easier for developers! • Cluster • Bucket • ClientConfiguration • ClusterHelper*
  14. 14. Cluster Object 14 • Maintains references to all open buckets • Should be a singleton (in most applications) • Maintains the current state of the Couchbase Cluster or Server • Publishes config updates • Factory for: ClusterManager
  15. 15. Bucket class 15 • “Super API” for all other APIs • Memcached (K/V) • Views • N1QL • Subscriber for config changes • Serialization/Deserialization • Transcoding
  16. 16. ClientConfiguration Class 16 • Configures bootstrapping, connection pooling and general client behavior • Maps (“adapts”) to config file • Allows for programmatic configuration of client • Contains useful defaults - e.g. http:localhost:8091 • Bucket level overrides Cluster level configuration
  17. 17. ClusterHelper 17 • Makes it “easy” to use the Cluster/Bucket • Cluster is a singleton • Buckets are multitons • It will make your life easier, use it
  18. 18. The IResult Interface 19 • As a rule the Bucket class doesn’t “throw” exceptions • IResult is the primary interface for return values of all APIs: • IViewResult • IOperationResult and IentityResult • IQueryResult • The interface defines • Message • Exception • Success • Other info defined in more specialized interfaces
  19. 19. .NET SDK Query options 21 • Key/value • Views (we will not cover views in this talk) • N1QL (pronounced nickel) • SQL like query language for Couchbase • “SQL for Documents”
  20. 20. Demo Querying data with the .NET SDK and N1QL
  21. 21. Linq2Couchbase The best from N1QL and LINQ 23
  22. 22. LINQ support for N1QL 24 Linq2Couchbase is a LINQ provider that wraps a subset of the available N1QL queries to LINQ • An extension of the Couchbase .NET SDK 2.0 • Open Source Apache 2.0 License (Pull requests kindly accepted!) • Github url: https://github.com/couchbaselabs/Linq2Couchbase • Currently supports a minimal subset of the N1QL language (this will soon change) • Errors are un-handled • Results are mapped to POCOs
  23. 23. Demo N1QL with LINQ
  24. 24. Best practices – Application Architecture and Abstractions Software design principles, maintainability and testable code strategies. “craftsmanship” 26
  25. 25. Design decisions 27 • N1QL in the UI layer? • Queries in the UI Layer? • Hard vs. Loose coupling to Couchbase SDK? • Testability? • Maintainability? • Separation of concerns…
  26. 26. The Repository Pattern 28 “Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.” - Martin Fowler • Creates an abstraction between BL and DAL • Makes it possible to write persistence store, agnostic apps • Enabler for TDD • In general, provides a common language and structure accessing data • If you don’t like the Repository, try DTO/DAO pattern or some other data access pattern…or not!
  27. 27. Demo Repository pattern 29
  28. 28. Couchbase .NET SDK version NEXT Knowledge about tomorrow can greatly help us plan today! 30
  29. 29. The Ubiquitous Repository 31 “Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.” - Martin Fowler • Creates an abstraction between BL and DAL • Makes it possible to write persistence store, agnostic apps • Enabler for TDD • In general, provides a common language and structure accessing data • If you don’t like the Repository, try DTO/DAO pattern or some other data access pattern…or not!
  30. 30. .NET SDK - Version Next 32 • async/await support • Observable support - Excepted ETA is April • LINQ to N1QL support in SDK - High priority, but no specific release date yet.
  31. 31. Summary 33
  32. 32. Resources 34 • .NET SDK https://github.com/couchbase/couchbase-net-client • Linq2Couchbase https://github.com/couchbaselabs/Linq2Couchbase • N1QL installer http://www.couchbase.com/nosql-databases/downloads • Azure Setup guide http://blog.couchbase.com/hosting-couchbase-server-in-windows-azure- part-1
  33. 33. Key take-aways 35 • Couchbase supports advanced data query with N1QL • LINQ support in the workings • async/await + Observable support just around the corner! • N1QL will be part of Couchbase Installer for GA (Sherlock). Contributions are highly appreciated especially around LINQ support for N1QL!
  34. 34. Forums forums.couchbase.com 36
  35. 35. Questions? 37
  36. 36. Thanks for listening! Martin Esmann Developer Advocate @ Couchbase Twitter: martinesmann martin@couchbase.com 38

×