Skip to content
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

Implemented Fluent Api based on @RoyGoode's code #1220

Closed
wants to merge 1 commit into from
Closed

Implemented Fluent Api based on @RoyGoode's code #1220

wants to merge 1 commit into from

Conversation

lancecontreras
Copy link

@lancecontreras lancecontreras commented Apr 3, 2024

I have noticed that there's been a few attempt to implement fluent api for sqlite-net in the past. The prominent one being from @roygoode.

This is my attempt to implement fluent API that is based on @roygoode's code. I also took to consideration the author's (@praeclarum) comment in #533. This should get rid of the requirement to use the attribute for table and columns.

Usage

    var mapping = TableMapping.Builder<SomeTable>()
        .TableName("some_table")
        .ColumnName(s => s.Name, "some_name")
        .AutoIncrement(s => s.MyId)
        .PrimaryKey(s => s.MyId)
        .Unique(s => s.MyId)
	.Build();
    								
    connection.UseMapping(mapping);
    connection.CreateTable<SomeTable>();

    // or 

   connection.CreateTable<SomeTable>(mapping); 

   // this also supports CreateTables(map1, map2, map3, ... ); 

I'm open to any comments and suggestions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant