MightyOrm / Mighty

A new, small, dynamic micro-ORM. Highly compatible with Massive, but with many essential new features.
BSD 3-Clause "New" or "Revised" License
101 stars 20 forks source link

Introduce a feature to create dynamic models faster #2

Closed brgrz closed 5 years ago

brgrz commented 5 years ago

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.

mikebeaton commented 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.)

mikebeaton commented 5 years ago

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.

mikebeaton commented 5 years ago

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.