ServiceStack.OrmLite: Where is the method to write custom SQL and get result set back?

旧街凉风 提交于 2019-12-06 09:26:17

Yeah I recently noticed that db.SqlList got lost in the OrmLite v4 refactor so I've restored it back in this commit. Which will be available in the next release of v4, before the end of the month.

You can still use db.Select for raw SELECT queries, e.g:

var results = db.Select<Poco>("SELECT * FROM a LIMIT 10");

It's only an issue when it's not a SELECT statement because we'd assume it's short-hand like:

var results = db.Select<Poco>("Foo = 'bar'");

And automatically add the rest of the SQL for you, but this is a problem when you're not issuing a SELECT statement, e.g. calling a stored procedure, which is what db.SqlList is for since the raw SQL remains untouched.

Support for LIMIT in Typed Expression API

Another way to query with a limit is to use the typed expression API, e.g:

var results = db.Select<Poco>(q => q.Limit(10));
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!