加入查询的Ormlite异常

时间:2014-10-16 07:30:36

标签: servicestack ormlite-servicestack

我在使用OrmLite工作时遇到了一些麻烦 - 我认为使用文档数据库时间太长了!鉴于我有以下模型:

public class ListingEvent
{
    public ListingEvent()
    {

    }

    [AutoIncrement]
    [PrimaryKey]
    public int Id {
        get ;
        set;
    }

    public string Name { get; set; }

    [ForeignKey(typeof(Location))]
    public int LocationId {
        get;
        set;
    }
}

public class Location 
{
    public Location()
    {
        ListingEvents = new List<ListingEvent>();
    }

    [AutoIncrement]
    [PrimaryKey]
    public int Id {
        get ;
        set;
    }

    public string Name { get; set; }

    [Reference]
    public List<ListingEvent> ListingEvents { get;  set; }
}

以下查询:

var listingEvents = db.Select<ListingEventDto> (
                    db.From<Model.ListingEvent>()
                    .Join<Model.ListingEvent, Model.Location> ()
                    .Where<Model.ListingEvent> (le => locationIds.Contains (le.LocationId) && le.Name.Contains (request.Query))
                    .Or<Model.ListingEvent, Model.Location>((le, l) => l.Name.Contains(request.Query) == true)
                    .Limit (skip: request.Skip, rows: request.Take));

为什么在地球上(记住我已经尝试了这个的每个内容!)我得到这个错误:

error CodeInvalidOperationException message variable 'l' of type 'Model.Location' referenced from scope '', but it is not defined

1 个答案:

答案 0 :(得分:0)

问题出在下面的表达式中,即连接表中列的方法表达式:

.Or<Model.ListingEvent, Model.Location>((le, l) => l.Name.Contains(request.Query))

此问题已解决in this commit,可从v4.0.33 + published to MyGet获得。