Reputation: 11995
I am trying to write a CodeAssignStatement
which does something equivalent to the following:
this.Foo = row.Field<string>(0);
How to write the RHS expression for the CodeAssignStatement
?
So far I only have:
CodeAssignStatement cas = new CodeAssignStatement();
cas.Left = new CodePropertyReferenceExpression(new CodeThisReferenceExpression(), "Foo");
cas.Right = ??!
Upvotes: 1
Views: 558
Reputation: 803
I think you want the CodeTypeReference
something like this: (Note that I haven't tested this fully, I've just created the graph - not actually rendered it to code)
cas.Right = new CodeMethodInvokeExpression(
new CodeMethodReferenceExpression(
new CodeVariableReferenceExpression("row"),
"Field",
new CodeTypeReference("System.String")),
new CodePrimitiveExpression(0));
Upvotes: 2