代码之家  ›  专栏  ›  技术社区  ›  David Gardiner

nhibernate linq throws“没有为类型”System.Collections.Generic.IList“1[System.Int32]”和“System.Int32”定义二元运算符equal”

  •  0
  • David Gardiner  · 技术社区  · 14 年前

    以下linq to nhibernate(使用nhibernate 3.0)导致引发System.InvalidOperationException,并显示消息“没有为类型”System.Collections.Generic.IList“1[System.Int32]”和“System.Int32”定义二进制运算符equal”

    public IEnumerable<ProjectSummary> GetProjects( IList<int> clients )
    {
        using ( var session = _sessionManager.OpenSession() )
        {
            var q = from p in session.Query<Project>()
                    where clients.Contains( p.Client.Id )
                    select new ProjectSummary()
                    {
                        ProjectId = p.Id,
                        Active = p.Active,
                        ClientId = p.Client.Id,
                        Name = p.Name
    
                    };
    
            return q.ToList();
        }
    }
    
    2 回复  |  直到 14 年前
        1
  •  4
  •   Alessandro Gianbattista Giorge    14 年前

    这个问题已经在后备箱里解决了。

    对于任何其他涉及Equals的System.NotSupportedExcipetion,您可以在我的博客上查看此文章: http://www.primordialcode.com/Blog/Post/nhibernate-3-extending-linq-provider-fix-notsupportedexception

        2
  •  0
  •   David Gardiner    14 年前

    使用 List<int> 而不是 IList<int>