0
我擴展Dynamic.cs以使其符合與索引器一起使用的資格。在這種情況下,我需要獲取存儲在調用表達式中的索引。在調試器中,我可以看到:如何獲取存儲在linq調用中的值表達式
- left {Param_0.get_Item(0)} System.Linq.Expressions.Expression {System.Linq.Expressions.InstanceMethodCallExpressionN}
- Arguments Count = 1 System.Collections.ObjectModel.ReadOnlyCollection<System.Linq.Expressions.Expression> {System.Runtime.CompilerServices.TrueReadOnlyCollection<System.Linq.Expressions.Expression>}
- [0] {0} System.Linq.Expressions.Expression {System.Linq.Expressions.ConstantExpression}
CanReduce false bool
DebugView "0" string
NodeType Constant System.Linq.Expressions.ExpressionType
+ Type {Name = "Int32" FullName = "System.Int32"} System.Type {System.RuntimeType}
Value 0 object {int}
+ Rohdatenansicht
我要的是:
left.Arguments[0].Value
我怎樣才能得到呢?
一個醜陋的方法可能會使用left.ToString()。這將導致:「Param_0.get_Item(0)」在那裏我可以提取get_Item()的參數。但我認爲這不是正確的方法。
什麼的Dynamic.cs? – svick 2012-02-16 11:49:03
@svick你知道谷歌;)。如果沒有,請看:[鏈接](http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library。 ASPX) – Schorsch 2012-02-16 18:28:39