开发者

How to change a global variable value based on linq query while executing

I have two module-level variables and Linq query. I want the results of the Let clause to change the global variables - is this possible?

For example:

Dim X As Integer = 0
Dim Y As Integer = 0
Sub One()
    Dim query = From e In <picture> _
                    Let X = e.@x _
                    Let Y = e.@y _
                Select <image X=<%= X %&g开发者_Go百科t; Y=<%= Y %>><%= Two() %></image>
End Sub
Function Two()
    Return <X><%= X %></X>
End Function

What I need to do is assign X and Y in Sub One's query and then have the query automatically use those updated values in Function Two. The Let clause does not allow me to do this as that only sets in-query variables. Does anyone know a solution to this?


You could pass X and Y as arguments to the function Two() eg

Sub One()
    Dim query = From e In <picture> _
                    Let X = e.@x _
                    Let Y = e.@y _
                Select <image X=<%= X %> Y=<%= Y %>><%= Two(X,Y) %></image>
End Sub

Function Two(X as int, Y as int)
    Return <X><%= X %></X>
End Function
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜