Closed aggieben closed 2 months ago
The compile-time type-checking is very intentional. I don't think there is easy way around that. Maybe:
1) If you know the schema is exactly same, the .GetDataContext
takes runtime connection string as parameter. That helps if they are totally separate identical databases, but maybe not with schemas?
2) You could do conditional compilation. Not runtime but to avoid duplicate code.
3) To share queries... Trying to write generic LINQ queries is not very easy in .NET because there is no ducktyping, Expression trees are typed strongly on compile time. There are some options listed in https://fsprojects.github.io/SQLProvider/core/composable.html#Composable-Queries but they may not suite for your need.
Got it. I read this as "for now there is no way". Thanks!
I'm using Postgres schemas to implement multitenancy; I've got a couple of meta-tables in the
public
schema, and then N other schemas (1 per tenant). The context types produced by the provider have static members for each schema provided at compile-time, but is there a way to switch which schema would be queried at runtime?