无法使用 ServiceStack Orm Lite 'select' 来自两个来源 table 的新 POCO

Unable to 'select' new POCO from two source table using ServiceStack Orm Lite

我正在尝试 select 使用 ServiceStack.OrmLite. I'm following the general syntax shown under C# 7 Tuples 使用来自多个不同源表的数据的 POCO,但返回具体的 POCO 而不是元组。我正在解析 SqlExpression.

 var exp = Db.From<TransactionProduct>()
                        .Join<Transaction>()
                        .Join<Product>()
                        .Join<Transaction, Device>()
                        .Select<Transaction, Device>((t, d) =>
                        new BottleBox
                        {
                            Location = d.Name,
                            Notes = t.Note,
                            Timestamp = t.TimeStamp
                        });

错误是:

Error CodeInvalidOperationException
Messagevariable 't' of type 'BMS.ServiceModel.Transactions.Transaction' referenced from scope '', but it is not definedStack

我在 SqlExpression "exp" 定义末尾的 Select 语句中似乎有一些错误,但我终究无法弄清楚发生了什么在....

自定义 select 投影应使用匿名类型:

.Select<Transaction, Device>((t, d) =>
    new {
      Location = d.Name,
      Timestamp = t.TimeStamp
    });

当select将结果集转换为特定的具体类型时,您会使用 POCO:

var results = db.Select<BottleBox>(q);