【问题标题】:Ormlite exception on joined query连接查询的 Ormlite 异常
【发布时间】:2014-10-17 15:43:29
【问题描述】:

我在让一些 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

【问题讨论】:

    标签: servicestack ormlite-servicestack


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 2011-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-11
      • 2013-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多