由网友(容我做个垃圾)分享简介:我有我使用到Data.DataTable由列数排序如下VB.NET code。I have the following VB.NET code that I am using to sort a Data.DataTable by column count.For Each dtTarget As Data.Dat...
我有我使用到Data.DataTable由列数排序如下VB.NET code。
I have the following VB.NET code that I am using to sort a Data.DataTable by column count.
For Each dtTarget As Data.DataTable In _
From x In Target.Tables _
Where DirectCast(x, Data.DataTable).Rows.Count > 0 _
Order By DirectCast(x, Data.DataTable).Columns.Count
...
Next
有一种方法,以指示x被一个Data.DataTable无需它被引用(在这种情况下,两次)每次DirectCast它在LINQ查询?
Is there a way to indicate that x is a Data.DataTable without having to DirectCast it each time it is referenced (twice in this case) in the LINQ query?
推荐答案
是这样的:
Target.Tables.Cast<Data.DataTable>()
,然后让你的那个查询。而且你应该正确地重构你code成几行,以使其更具可读性。
and then make your query of that. And you should properly refactor you code into several lines to make it more readable.
(这是C# - 但我把它翻译,2秒)
(this is C# - but I will translate it, 2 sec)
翻译:
Dim query = From x In Target.Tables.Cast(Of Data.DataTable)() _
Where x.Rows.Count > 0 _
Order By x.Columns.Count _
Select x
For Each dtTarget As var In query
...
Next
相关推荐
最新文章