Design discussion: OfflineDbContext #53
Closed
adrianhall
started this conversation in
Ideas
Replies: 2 comments
-
Option #2: Using an On… protected function: public class MyOfflineDbContext(DbContextOptions<MyOfflineDbContext> options) : OfflineDbContext(options)
{
// Your offline data sets are defined as normal; you can also use OnModelCreating() as normal as long as you call base.
public DbSet<Movie> Movies => Set<Movie>();
// Use OnDatasyncInitialization() to set datasync settings
Protected override void OnDatasyncInitialization(DatasyncContextBuilder contextBuilder)
{
contextBuilder.SetHttpClient(new HttpClient() { BaseAddress = “https://my-datasync-server.azurewebsites.net/“ });
ContextBuilder.Entity<Movie>().SetUri(new Uri(“/tables/movies”, UriKind.Relative));
}
} (With apologies for capitalization - apparently, writing code on an iPad is hard) |
Beta Was this translation helpful? Give feedback.
0 replies
-
Based on the complete lack of replies, I’m going to assume no-one cares as long as it works. I’m going to use Option 2 (above) - having a protected builder initialization method (which is how OnConfiguring and OnModelCreating work as well). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to garner opinions on this API.
The new client will be centered around offline capabilities by requiring you to integrate into an Entity Framework Core DbContext - or rather a sub-class of it (called
OfflineDbContext
). Here is the proposed typical OfflineDbContext definition:If you want to pull the movies table, you can use:
If you want to use a query, you can use:
Thoughts on this overall flow for pulling data?
(And yes, pushing, I'll be covering remote table access and pushing tables in a later discussion)
Beta Was this translation helpful? Give feedback.
All reactions