Introduction to FluentDataLars-Erik KindbladSenior ConsultantBlog: kindblad.com
Agenda   What is FluentData?   Why was FluentData created?   Architecture   Sample code   Road map                   ...
What is FluentData?   Micro ORM for .NET   Makes it simple to query a relational database   Open Source   MIT license...
Why was FluentData created? ORMs such as Entity Framework and NHibernate have too many  disadvantages  • Framework is too...
Alternatives to ORMs? ADO.NET •   Powerful •   Flexible •   Great performance •   ... but too much manual code           ...
A Better Alternative?    ORM             Micro ORM            ADO.NETSecure                                 FastAuto mappi...
Micro ORM Uses SQL – the native and optimized query language for databases,  rock solid – in use since the 70s Thin wrap...
Goals of FluentData Easy to learn Simple and efficient to use Fast Secure Single DLL Only the Data Access Layer shou...
Features Fluent API Supports SQL Server, SQL Server Compact, SQL Azure, Access,  MySQL, Oracle Use SQL to select data a...
Architecture               | Sector, Alliance, Offering
DbContext Starting point for working with FluentData Use it to define settings such as  • ConnectionString or Connection...
DbCommand Responsible for performing the actually query against the database                                             ...
Mapping FluentData can automap query results to your own entity type or to a  dynamic type (new in .NET 4.0) or you can ...
Builders Fluent API to generate SQL for insert, update and delete queries                                                ...
Sample Code
Getting started Download FluentData.dll from either  • FluentData.CodePlex.com  • NuGet Add a reference to FluentData.dl...
ModelDatabase .NET           | Sector, Alliance, Offering
Create and Initialize the DbContext                                      | Sector, Alliance, Offering
INSERT DATA              | Sector, Alliance, Offering
Insert a Category       SQL      Builder                    | Sector, Alliance, Offering
UPDATE DATA              | Sector, Alliance, Offering
Update a Product                   | Sector, Alliance, Offering
DELETE DATA              | Sector, Alliance, Offering
Delete a Product                   | Sector, Alliance, Offering
SELECT DATA              | Sector, Alliance, Offering
Select a Category                    | Sector, Alliance, Offering
Select all Categories Map to List<Category> Map to CategoryCollection                             | Sector, Alliance, Offe...
Select all Products with the related Category                Auto Mapping                                                |...
Select all Products with the related Category             Manual Mapping                                                | ...
Count the number of Products                               | Sector, Alliance, Offering
Select All Categories + All Products                                       | Sector, Alliance, Offering
Select Products 1,2,3,4                          | Sector, Alliance, Offering
TRANSACTIONS               | Sector, Alliance, Offering
Insert multiple products within a Transaction                                                | Sector, Alliance, Offering
Road map Add support for more databases  • SQLite, PostgreSQL + Add a Select Builder with Paging support and strongly ty...
QUESTIONS?             | Sector, Alliance, Offering
www.capgemini.comThe information contained in this presentation is proprietary. ©2010 Capgemini. All rights reserved
Upcoming SlideShare
Loading in...5
×

Introduction to FluentData - The Micro ORM

2,907

Published on

Lars-Erik Kindblad presentation at the Capgemini Microsoft User Group 2012.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,907
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
59
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Introduction to FluentData - The Micro ORM"

  1. 1. Introduction to FluentDataLars-Erik KindbladSenior ConsultantBlog: kindblad.com
  2. 2. Agenda What is FluentData? Why was FluentData created? Architecture Sample code Road map | Sector, Alliance, Offering
  3. 3. What is FluentData? Micro ORM for .NET Makes it simple to query a relational database Open Source MIT license http://fluentdata.codeplex.com NuGet: FluentData | Sector, Alliance, Offering
  4. 4. Why was FluentData created? ORMs such as Entity Framework and NHibernate have too many disadvantages • Framework is too complex • Forces you to design the .NET Model in a special way by using attributes and ORM Framework specific types • Hard to define the mapping between the database model and business model • A lot of mapping code/XML – not any less code than SQL and manual mapping • Uses an abstracted query language instead of SQL o Hard to do complex queries, Generates poor SQL, Slow • Takes a long time to learn and master • Drag and drop designers are buggy and limiting • = Leads to unpredictable development time and performance ... had to be a better way to do it | Sector, Alliance, Offering
  5. 5. Alternatives to ORMs? ADO.NET • Powerful • Flexible • Great performance • ... but too much manual code | Sector, Alliance, Offering
  6. 6. A Better Alternative? ORM Micro ORM ADO.NETSecure FastAuto mapping Simple Flexible Fast Predictable Flexible Manual mapping Predictable Secure Auto mapping Manual mapping | Sector, Alliance, Offering
  7. 7. Micro ORM Uses SQL – the native and optimized query language for databases, rock solid – in use since the 70s Thin wrapper layer on top of ADO.NET: • Reduce repetitive code • Support auto mapping Map per query instead of per Entity = Result • Fast • Simple • Efficient | Sector, Alliance, Offering
  8. 8. Goals of FluentData Easy to learn Simple and efficient to use Fast Secure Single DLL Only the Data Access Layer should be affected by FluentData Select queries should be SQL, insert, update and delete queries can be SQL or generated Support the major databases | Sector, Alliance, Offering
  9. 9. Features Fluent API Supports SQL Server, SQL Server Compact, SQL Azure, Access, MySQL, Oracle Use SQL to select data and builders to insert, update, delete data Supports • Auto mapping and custom mapping • Stored Procedures • Transactions • Multiple result sets • Custom collections eg. ProductCollection instead of List<Product> • Provider model • ++ | Sector, Alliance, Offering
  10. 10. Architecture | Sector, Alliance, Offering
  11. 11. DbContext Starting point for working with FluentData Use it to define settings such as • ConnectionString or ConnectionStringName • UseTransaction Hook up your own method to any of the supported events • OnConnectionOpened • OnConnectionOpening • OnConnectionClosed • OnExecuting • OnExecuted • OnError | Sector, Alliance, Offering
  12. 12. DbCommand Responsible for performing the actually query against the database | Sector, Alliance, Offering
  13. 13. Mapping FluentData can automap query results to your own entity type or to a dynamic type (new in .NET 4.0) or you can map the query results manually | Sector, Alliance, Offering
  14. 14. Builders Fluent API to generate SQL for insert, update and delete queries | Sector, Alliance, Offering
  15. 15. Sample Code
  16. 16. Getting started Download FluentData.dll from either • FluentData.CodePlex.com • NuGet Add a reference to FluentData.dll in your Data Access Project | Sector, Alliance, Offering
  17. 17. ModelDatabase .NET | Sector, Alliance, Offering
  18. 18. Create and Initialize the DbContext | Sector, Alliance, Offering
  19. 19. INSERT DATA | Sector, Alliance, Offering
  20. 20. Insert a Category SQL Builder | Sector, Alliance, Offering
  21. 21. UPDATE DATA | Sector, Alliance, Offering
  22. 22. Update a Product | Sector, Alliance, Offering
  23. 23. DELETE DATA | Sector, Alliance, Offering
  24. 24. Delete a Product | Sector, Alliance, Offering
  25. 25. SELECT DATA | Sector, Alliance, Offering
  26. 26. Select a Category | Sector, Alliance, Offering
  27. 27. Select all Categories Map to List<Category> Map to CategoryCollection | Sector, Alliance, Offering
  28. 28. Select all Products with the related Category Auto Mapping | Sector, Alliance, Offering
  29. 29. Select all Products with the related Category Manual Mapping | Sector, Alliance, Offering
  30. 30. Count the number of Products | Sector, Alliance, Offering
  31. 31. Select All Categories + All Products | Sector, Alliance, Offering
  32. 32. Select Products 1,2,3,4 | Sector, Alliance, Offering
  33. 33. TRANSACTIONS | Sector, Alliance, Offering
  34. 34. Insert multiple products within a Transaction | Sector, Alliance, Offering
  35. 35. Road map Add support for more databases • SQLite, PostgreSQL + Add a Select Builder with Paging support and strongly typed auto mapping Simplify code Single Source File Performance improvements .NET intellisense for the database model | Sector, Alliance, Offering
  36. 36. QUESTIONS? | Sector, Alliance, Offering
  37. 37. www.capgemini.comThe information contained in this presentation is proprietary. ©2010 Capgemini. All rights reserved
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×