代码之家  ›  专栏  ›  技术社区  ›  Femaref

亚音速3.x:查询时ArgumentException(LINQ)

  •  0
  • Femaref  · 技术社区  · 16 年前

    即使是像这样的简单查询

    EmmaDatabase.EmmaDB ec = DatabaseProvider.GetEmmaDatabase();
    var changes = (from o in ec.dbCachedChanges
                               select o);
    

    at System.Linq.Expressions.Expression.Bind(MemberInfo member, Expression expression)
    

    这对我毫无帮助。我不知道这是为什么造成的,在这里没有发现任何东西,也没有谷歌搜索。

    编辑:异常根本不会改变结果,异常只会消耗时间。

    有人能帮我吗?

    1 回复  |  直到 16 年前
        1
  •  2
  •   Femaref    16 年前

    解决了,不是断路器,只是异常编码。

    亚音速。核心。Linq。结构。查询映射。cs:155

    if (me != null)
    {
        try {
                bindings.Add(Expression.Bind(mi, me));
        } catch {
            //this is only here until I rewrite this whole thing
        }
    }
    

    if (me != null)
    {
        try {
            if (mi is PropertyInfo && ((PropertyInfo)mi).PropertyType.IsAssignableFrom(me.Type))
                bindings.Add(Expression.Bind(mi, me));
            else if (mi is FieldInfo && ((FieldInfo)mi).FieldType.IsAssignableFrom(me.Type))
                bindings.Add(Expression.Bind(mi, me));
        } catch {
            //this is only here until I rewrite this whole thing
        }
    }
    

    因为QueryMapper.GetMappedMembers()返回的列表仅包含PropertyInfo和FieldInfos。