-
Notifications
You must be signed in to change notification settings - Fork 50
Upgrading from v2 to v3
V3 was a complete rewrite of SqlFu and my objective was to have an extremely versatile data mapper that allows me a middle path between Ado.Net and ORM. Think of it as strongly typed Ado.Net or similar :)
The biggest change is that of the mindset. As long as you consider SqlFu to be a data mapper on steroids or a collection of helpers sitting on top of Ado.Net, everybody's happy :) . Even though SqlFU features a strongly typed query builder it is not Linq and SqlFu never does relational mapping i.e it's not a ORM and it will never be one.
The strongly typed builder is meant to be used for one table/view simple enough queries. For everything involving joins use views or sprocs. You can define your own helpers to implement db specific functions or keywords if you want to have everything strongly typed. In SqlFu 3 the idea is to think in Sql but write C#. That's why the builder mimics the normal sql query instead of being Linq like. SqlFu is never about abstraction, we want to use the RDBMS at its fullest, however without involving magic strings.
All configuration is done as part of SqlFuManager
's Configure()
method. v3 adds support for multiple providers enabling you to work with more than one db in the same app. However, it requires to specify explicitly a db provider which will act as default.
Custom type/values converters should be added here, too. No more working with PocoFactory.
In v3 the SqlFuManager returns factories as opposed to a simple connection like in v2. This is required for multiprovider support. Probably the easiest way to migrate is to define your own SqlFuDao
adapter mimicking SqlFu v2 GetConnection()
behaviour.
Simple queries involving strings should work without change, I've tried to maintain as much compatibility as I could. However, helpers such as 'Count' were dropped. The Insert/Update/Delete helpers were kept but rewritten so most of them are not compatible.
- Migrations support
- Table attributes. There is still a
[Table]
but different and it should be used as last resort. Best thing is to configure the table creation with plain sql (via some migration script/tool) or using the strongly typed storage creator class. It's important to mention that no attributes are used to map things from objects to tables, because SqlFu is not an ORM. - Buddy class