简体   繁体   English

ServiceStack.OrmLite“ LoadSelect”不能加载IEnumerable引用吗?

[英]Can ServiceStack.OrmLite “LoadSelect” not load IEnumerable references?

Given the following abbreviated DTO's... 鉴于以下缩写DTO的...

public class Order
{
    public int ID { get; set; }
    [References(typeof(Customer))]
    public int? CustomerID { get; set; }
    [Reference]
    public List<OrderItem> OrderItems { get; set; }        
}

public class OrderItem
{
    public int ID { get; set; }
    [References(typeof(Order))]
    public int? OrderID { get; set; }
    public string ProductID { get; set; }

    [Reference]
    public Product Product { get; set; }
}

...with the following service... ...具有以下服务...

[Route("/orders", "GET")]
public class GetOrders : IReturn<IEnumerable<Order>>
{
    public int? Page { get; set; }
    public int? Show { get; set; }
}

public class OrderService : Service
{
    public List<Order> Get(GetOrders request)
    {
        var query = Db.From<Order>()
            .OrderByDescending(q => q.ID)
            .Limit(request.Page.GetValueOrDefault(0) * request.Show.GetValueOrDefault(25), request.Show.GetValueOrDefault(25));

        return Db.LoadSelect(query);
    }
}

The LoadSelect will properly load the Customer reference, but it will not load the OrderItems reference. LoadSelect将正确加载Customer参考,但不会加载OrderItems参考。 Is there a way to force it to? 有办法强迫它吗? I've tried throwing in a Join to force it, but anything I try seems to either bomb because of the OrderBy and Limit, or it will return the entire dataset before limiting which kills performance. 我已经尝试过Join来强制执行它,但是我尝试执行的任何操作似乎都因为OrderBy和Limit而炸弹,或者它会在限制性能之前先返回整个数据集。

Am I missing something, or is this not supported? 我是否缺少某些内容,或者不支持此功能?

Firstly I recommend using Id naming convention instead of ID when using ServiceStack libraries. 首先,我建议在使用ServiceStack库时使用Id命名约定而不是ID

This looks like it's a similar issue to the loading reference data with LoadSelect in SqlServer in a paged query that has been resolved in the latest v4.0.34+ which is now available on MyGet . 看起来这与在分页查询中使用SqlServer中的LoadSelect加载参考数据存在类似的问题 ,该问题已在最新的v4.0.34 +中解决, 现在可在MyGet上使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM