tags:

views:

41

answers:

1

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 Exception doesn't change the outcome at all, the exception just eats time.

Anybody able to help me?

+2  A: 

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.

Femaref