Closed brgrz closed 5 years ago
Sounds like a reasonable idea!
I'd initially think of doing it as a static variable on the MightyORM
class - set once, creates a default value which is used, whenever connection string not specified, for any instances created in the same AppDomain
scope.
(Would, therefore, not support any kind of requirement for different defaults in different contexts - but at that level of complexity and above, I think it would be fair enough to expect the user to program what they want and need.)
Note that in .NET Framework, this is supported in Mighty (it was supported but buggy in Massive): the first user ConnectionString in app.config is used (and the number of global connection strings in machine.config is correctly accounted for in order to fetch this, which is the change from Massive).
But yes, it is easy to add this, and it might be convenient in .NET Core.
Okay, we now have MightyOrm.GlobalConnectionString
which will be used by all instances of MightyOrm
and MightyOrm<T>
if no connection string is passed in. It's in the Async
branch for now.
Currently every instance of MightyORM requires us to provide connection string.
If there was some kind of factory or helper class that we could register within our DI and use that to create new dynamic model instances, that would be great.