在Linq中使用变量 [英] Use variables in Linq
本文介绍了在Linq中使用变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我使用sql时我可以这样做
" SELECT * from" &安培;菜单
& " WHERE(("& Menus&" .ItemName)='"& dfd
&"'));"
我可以通过更改
变量菜单来选择哪个表
但是当我在
linq语句中尝试相同的技术
< p class = MsoNormal>
Dim MyItem =来自我的直流电。"&菜单
& "选择我
它不起作用
解决方案
不,但您可以使用变量来存储要查看的表,然后使用switch语句或反射来执行相同的操作。
When I was using sql I could do that
"SELECT * from " & Menus & " WHERE (((" & Menus & ".ItemName)= '" & dfd & "' )) ;"
I can chose which table by changing the variable Menus
But when I try the same technique in linq statement
Dim MyItem= from I in dc." & Menus & " select I
it does not work
解决方案
No, but you could use a variable to store the table that you want to look at and then either use a switch statement or reflection to do pretty much the same thing.
这篇关于在Linq中使用变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文