开发者

Subsonic 3.x: ArgumentException while querying (LINQ)

开发者 https://www.devze.com 2022-12-13 04:40 出处:网络
Even a simple query like EmmaDatabase.EmmaDB ec = DatabaseProvider.GetEmmaDatabase(); var changes = (from o in ec.dbCachedChanges

Even a simple query like

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

Throws me an ArgumentException (Argument types do not match) while iterating over it. The Stacktrace only contains

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

which is totally not helping me. I have no idea why this is caused and found nothing here nor googling.

EDIT: The Except开发者_运维技巧ion doesn't change the outcome at all, the exception just eats time.

Anybody able to help me?


Solved, wasn't a breaker, just coding by exception.

Subsonic.Core.Linq.Structures.QueryMapping.cs:155

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

can be solved by

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
    }
}

because QueryMapper.GetMappedMembers() returns a list containing only PropertyInfos and FieldInfos.

0

精彩评论

暂无评论...
验证码 换一张
取 消