why OrmLite CRUD operations don’t take Type argument?
FYI here’s an example using an untyped api: https://github.com/ServiceStack/ServiceStack.OrmLite/commit/bc9ccc122477c198acd91c247aaacbc3d6e500bf
It was only for internal use so it only contains Apis for Save’ and ‘SaveAll’, but I’ll extend them now and make them more usable.
? can you be more specific with an example?
object obj = Activator.CreateInstance(type);
BaseClass bc = (BaseClass) obj;
db.Insert(bc); // same UpdateNonDefaults, etc.
// <- Trying insert into BaseClass table instead of table from type
And i can’t find Insert method with Type argument.
Well it’s because it’s a generic type argument so it uses the type of the POCO as expected. Also a lot of API’s requires a generic type in order to provide a typed expression and most of the use-cases you’re working directly with the POCO so it’s not ideal to unnecessarily pollute the API with partially equivalent untyped API’s where its possible.
Anyway I do have an API I’m using for untyped access, I’ll see if I can create a test showing it with the example above.
It looks like we have same results. But I found limit of this. When we need call Select (or methods with expression) then i don’t know how to put expression into argument (because is typed).
That’s what I was saying when when I said: "a lot of API’s requires a generic type in order to provide a typed expression"
Anyway I’ve re-factored the untyped API to be more user-friendly and include more CRUD methods at:
These changes are now on MyGet:
Thank you very much