これまでのところ、Linqは、仮想プロパティではなく、クラスの既存のフィールドとプロパティで使用できることがわかりました。つまり、動的Linqであっても、ITypedListはLinqでは機能しません。
次のコードを試しました。
IQueryable contact ; ...
dynamic l = contact.Select("Customer.Name as Name");
// Customer is a virtual property provided by the interface of ITypedList.
次に、「タイプ'Contact'にlinkedPropertyNameまたはフィールド'Customer'が存在しません」という例外に遭遇しました。
動的Linqをトレースしたところ、次のコードで例外が発生していることがわかりました。
MemberInfo member = FindPropertyOrField(type, id, instance == null);
if (member == null)
throw ParseError(errorPos, Res.UnknownPropertyOrField,
id, GetTypeName(type));
return member is PropertyInfo ?
Expression.Property(instance, (PropertyInfo)member) :
Expression.Field(instance, (FieldInfo)member);
Expression ParseMemberAccess(Type type、Expression instance)のメソッド内。
Linqでサポートされているのは、フィールドとプロパティの実際のメンバーだけであることは明らかです。
しかし、仮想プロパティでLinqを実行する方法を誰かが見つけた可能性があることを私はまだ期待しています。
あなたがそうする方法を見つけたら、あなたの経験を共有してください。
前もって感謝します、
イン