开发者

Subsonic 3.x: ArgumentException while querying (LINQ)

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜