开发者

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

开发者 https://www.devze.com 2022-12-10 19:56 出处:网络
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?

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

精彩评论

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