我正在使用ServiceStack.OrmLite(版本3.8.5),我有以下内容:
var report = dbCommand.Select<UploadedMediaReport>(x => x.Id == message.Id &&
(int)x.BitRate == (int)message.BitRate &&
(int)x.MediaFormat == (int)message.Format
).FirstOrDefault();
,其中
public class UploadedMediaReport
{
public MediaBitRate BitRate { get; }
public MediaFormat Format { get; }
..
}
对于生成的SQL,使用枚举的字符串值而不是int值,即。错误的SQL是:
select ... bitRate = 'High' and Format = 'MP4'
应该在哪里
select ... bitRate = 1 and Format = 3
如何更改它以使其有效?
答案 0 :(得分:2)
我不确定您所看到的是否是一个错误,但可能的解决方法是:
var report = dbCommand.Where<UploadedMediaReport>(
new {
Id = message.Id,
BitRate = (int)message.BitRate,
MediaFormat = (int)message.Format
}).FirstOrDefault();