我花了很多时间在这个问题上.我可以做一个简单的Group By LINQ查询(在一个属性上)但是对于多个字段我有点卡住......这是我想要做的LINQPad示例:
dim lFinal={new with {.Year=2010, .Month=6, .Value1=0, .Value2=0},
new with {.Year=2010, .Month=6, .Value1=2, .Value2=1},
new with {.Year=2010, .Month=7, .Value1=3, .Value2=4},
new with {.Year=2010, .Month=8, .Value1=0, .Value2=1},
new with {.Year=2011, .Month=1, .Value1=2, .Value2=2},
new with {.Year=2011, .Month=1, .Value1=0, .Value2=0}}
Dim lFinal2 = From el In lFinal
Group el By Key = new with {el.Year,el.Month}
Into Group
Select New With {.Year = Key.Year, .Month=Key.Month, .Value1 = Group.Sum(Function(x) x.Value1), .Value2 = Group.Sum(Function(x) x.Value2)}
lFinal.Dump()
lFinal2.Dump()
Run Code Online (Sandbox Code Playgroud)
lFinal列表有6个项目,我希望lFinal2有4个项目:2010-6和2011-1应该分组.
提前致谢.
我有两个自定义对象列表:
List1: Year, Month, ValueA
List2: Year, Month, ValueB
Run Code Online (Sandbox Code Playgroud)
我想得到第二个List,两者合并:
List3: Year, Month, ValueA, ValueB
Run Code Online (Sandbox Code Playgroud)
在LINQ VB.Net中有没有优雅的方法来执行它?
例:
List1:
2010 - 6 - 2
2010 - 7 - 5
2010 - 10 - 3
List2:
2010 - 7 - 2
2010 - 8 - 1
2010 - 10 - 2
List3 (result):
2010 - 6 - 2 - 0
2010 - 7 - 5 - 2
2010 - 8 - 0 - 1
2010 - 10 - 3 - 2 …Run Code Online (Sandbox Code Playgroud) 我的应用程序(通过 ClickOnce 部署的 vb.net windows 应用程序)使用 Word 打开和填充 .dot 模板以创建新的 Word 文档。我参考了 Microsoft Word 14 Object Library 并使用了以下代码:
Dim oWord As Word.Application = Nothing
Dim oDoc As Word.Document = Nothing
Try
oWord = New Word.Application
Dim strFileName As String = ""
Select Case strType
Case "LettreReception"
strFileName = Path.Combine(GetParam(1), "Template_LettreReception.dot")
If File.Exists(strFileName) Then
oDoc = oWord.Documents.Add(strFileName)
Run Code Online (Sandbox Code Playgroud)
在最后一行,我在部署的机器上(不是在我的开发机器上)收到“无法打开宏存储”错误。
我使用 Windows 7 - Office 2010 - VS 2010 (.Net 3.5) 进行开发。我的部署机器也是安装了 Office 2010 的 Windows 7。
我试图删除 normal.dotm(我发现了一些建议它的链接)但没有成功。使用的 .dot 模板不包含宏。