Then I have some code that sets the property on the object. This code is from an internal verification class which we are using in unit tests. Something like the code
can be suppliedThis code is a unit-test type environment, where we can then call
(Simplified code for brevity / complexity)
However, due to some refactorings, we are left with something like this:
foreach (string current credentials value in test casease) {BusinessObject myCustomer = new BusinessObject (); SetDeepValue (myCustomer, () = & gt; myCustomer.NameInfo.First, Current TestCaseValue); ValidateBusinessRules (myCustomer); }
Runs this code, we get the error.
object does not match the target type
I suspect that this is the first
property instead of the name code Trying to call BusinessObject
. How can I modify my code to handle this 'Nest' case?
After
Here you can usually change the string to "columnname 1. columnname 2"
in a lambda expression x = & gt; X.ColumnName1.ColumnName2
:
Expressions & lt; & Lt; T, Object & gt; & Gt; Prohibited property (string columnname) {// X parameter expansion para = expression Parameter (typef (t), "x"); // x.ColumnName1.ColumnName2 Expression Property = Columnname.LimP ('.') .Gregate & lt; String, Expression & gt; (Ultimate, (C, M) => Expression Property (C, M)); // x = & gt; X.ColumnName1.ColumnName2 expression & lt; Func & lt; T, Object & gt; & Gt; Lambda = expression. Lambda & lt; Func & lt; T, Object & gt; & Gt; (Expression. Conversion (property, type (object)), absolute); Return lambda; }
(copied)
No comments:
Post a Comment