English 中文(简体)
ServiceStack OrmLite, custom/raw query, deserializing to Model types
原标题:

I m trying to execute a customized query and I don t want to involve OrmLite for anything other that the mapping from IDataReader to a defined ServiceStack model type.

Currently, I m doing something like this:

var result = con.Exec(command => {
    command.AddParam("now", DateTimeOffset.Now, dbType: System.Data.DbType.DateTimeOffset);
    return command.ConvertTo<T>($@"BEGIN TRANSACTION;
        WITH cte AS (
            SELECT TOP(1) *
            FROM {con.Connection.GetQuotedTableName<T>()} with (rowlock, readpast)
            WHERE {statusColumnName} = {(int)QueueItemStatus.Ready}
            order by {idColumnName})
        UPDATE cte SET
            {statusColumnName} = {(int)QueueItemStatus.Locked},
            {lockedColumnName} = @now,
            {doneColumnName} = NULL
        OUTPUT deleted.*;
        COMMIT;");
});

I ve seen SqlList<T>(string sql) but it looks that method doesn t adhere to ServiceStack s annotations (Alias, etc).

问题回答

暂无回答




相关问题
Does ServiceStack support binary responses?

Is there any mechanism in ServiceStack services to return streaming/large binary data? WCF s MTOM support is awkward but effective in returning large amounts of data without text conversion overhead.

How do you implement authentication in servicestack.net

I m investigating servicestack.net - but it s examples and articles don t seem to cover authentication - is this something handled by servicestack.net - and if so how? In particular I m interested in ...

Redis Expire does not work

I use ServiceStack.Redis (build from the latest sources: https://github.com/ServiceStack/ServiceStack.Redis/tree/master/src). I do something like this: CacheRecord foundKey = cacheRecords.GetById(...

ServiceStack: how to deal with errors?

I m using ServiceStack with great results so far, except that dealing with errors is seemingly tricky. If something goes wrong during serialization of a message (because I forgot to add a default ...

ServiceStack.Text JSON parsing on .Net 4.0

H chaps, I am trying to use ServiceStack.Text for JSON parsing (it seems to be performing better than JSON.Net in various benchmarks I have seen). But I am not getting the results I am expecting. The ...

热门标签