-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Fluent API (v2) #727
base: master
Are you sure you want to change the base?
Add Fluent API (v2) #727
Conversation
Merge in latest sqlite-net enhancements
This is necessary to allow for ColumnMapping and TableMapping to have derived classes in the next step of Fluent API development
Implements the original functionality of TableMapping.Column for building column definitions from classes decorated with attributes, to allow the functionality to be kept separate from the new Fluent API
Implements the original functionality of TableMapping for building table definitions from classes decorated with attributes, to allow the functionality to be kept separate from the new Fluent API
This provides a common API for indices created by the original attribute-based implementation and the new Fluent API implementation so they can be used interchangeably
This will be used by the Fluent API version(s) of the CreateTable method(s) to add or replace mappings created without using attributes
This will be used for parsing properties from expressions in the Fluent API
Allows building table mappings using a Fluent API
Call this method to create a new instance of TableMappingBuilder<T> to use the Fluent API to build table mappings
This will be used internally to create tables in the database based on given table mappings
CreateTable(), CreateTables(), CreateTableAsync(), CreateTablesAsync() Used for creating tables based on the provided table mapping, generated from TableMappingBuilder
So you can use the new CreateTable(TableMapping…) methods with the original attribute-based implementation of table mappings if you really want to
Because this method is useful for supplying table mappings for query results, if you really need to specify column names without decorating those classes with attributes
Useful for querying the database with strongly-typed results for those that use the Fluent API to create table mappings
This implementation was missing from the Fluent API but was available via TableAttribute
TableQuery constructor that accepts TableMapping
Based on previous CreateTable tests
Between Fluent API and Attribute API (Fixes bug that failed new unit tests for Fluent API)
This looks great. @praeclarum is there any chance of this being merged? |
Any updates for this? |
Awaiting for this feature. |
@praeclarum I'm also in need to use model classes from different assemblies to store then in tables, so the feature in this PR looks as it works be the solution. How can I help in integrating this PR to sqlite-net? Or is there any other way to specify TableMappings for arbitrary types? Thanks! |
I've made a fork of current repo and merged manually changes from old RoyGoode(thx!) code. I will play with it and maybe use it. |
@praeclarum SQLite-Net is a really useful repo and I would love to see the Fluent API feature being implemented! |
This seems to be very old, most of the changes are not compatible with the latest. I'll try to build out of @roygoode's code and see if I can at least make it work with the latest master. |
I don't remember exactly, but I think there were some problems in @roygoode PR. I took his code 4 years ago and fixed them, check my fork. I'm using his fluent api with fixes for 4 years already. |
The changes made in this pull request allow tables to be created using a Fluent API with attribute-free objects (aka POCOs). This allows for cleaner separation of layers and aids dependency injection by not requiring references to sqlite-net to decorate model classes with attributes.
Example usage:
Based on the following example plain model classes...
The additional code recycles existing functionality for creating table mappings from attributes.