Skip to content

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