这是我的查询:
from forum in Forums
join post in Posts on forum equals post.Forum into postGroup
from p in postGroup
where p.ParentPostID==0
select new
{
forum.Title,
forum.ForumID,
LastPostTitle = p.Title,
LastPostAddedDate = p.AddedDate
}).OrderBy(o=>o.ForumID)
Run Code Online (Sandbox Code Playgroud)
目前,Join不是左连接,这意味着如果某个论坛没有属于它的帖子,则不会返回.
没有帖子的论坛必须返回post属性的null(或默认)值.
UPDATE
结果集应该是这样的:
ForumId | ForumTitle | LastPostTitle | LastPostAddedDate
--------+------------+---------------+------------------
4 | Sport | blabla | 12/4/2010
4 | Sport | blabla | 15/4/2010
6 | Games | blabla | 1/5/2010
7 | Flame | |
Run Code Online (Sandbox Code Playgroud) 我只想保留Tomcat Access Log Valve创建的最近n天的访问日志. http://tomcat.apache.org/tomcat-6.0-doc/config/valve.html#Access%20Log%20Valve
但似乎没有配置属性来定义保留日志文件的时间长度?我想这是因为"Access Log Valve"只创建日志文件并且不删除它们,这是正确的吗?
我有一系列ID,如127415157,31323794 ...(范围未知).在PHP中找到最大频率ID的最快方法是什么?
$array_ids = array()
Run Code Online (Sandbox Code Playgroud) 我想知道单独执行条件循环需要多长时间.就像我可以选择使用"if else","while","for"或"foreach"循环那么循环会更快地执行.我知道差异会非常小,大多数人会说它不会但是,如果我有一个可以访问数千个数据的程序,那么这一点就会出现.
我想知道我是否在java的开头声明了一个变量,如果我在使用它之前声明它将会有所不同.是否会减少所需的总时间?如果是,则实际使用哪一个(变量在开头声明或者它们刚被声明为b4的那个被使用)?
在我正在编辑的字典文件中,我经常需要在<>的位置插入字符"◊".有没有办法将"◊"映射到某个键,这样我按"r"代替,然后my_shortcut将<>替换为"◊"?我找到了一种在.vimrc中制作imap映射的方法:
:imap <> ?
Run Code Online (Sandbox Code Playgroud)
但是更改为插入模式是次优的,是否可以将它全部置于替换模式中,我应该在.vimrc中写什么?
是否有一个Windows API可以实现相当于单击"日期和时间属性"/"Internet时间"选项卡中的"立即更新"按钮(通过双击任务栏中的时钟打开)?
有没有办法监视窗口何时触发时间同步以及何时成功或失败?
我使用setContentOffset方法自动滚动到特定点而无需用户交互.
[menuScrollView setContentOffset:CGPointMake(600.0,0) animated:YES]
Run Code Online (Sandbox Code Playgroud)
但是当我尝试以循环方式调用相同的方法以减慢滚动的速度时,滚动永远不会发生
for (int i = 1; i<=30; i++) {
[menuScrollView setContentOffset:CGPointMake(600.0-i*10,0.0) animated:YES];
NSLog(@"%f",600.0-i*10);
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码片段中,UIScrollview的滚动只发生一次(第一次迭代(并且它不会滚动剩下的29次交互.这里有什么问题?
我正在使用Microsoft UI Automation(即AutomationElement)对我的应用程序运行自动化验收测试。一切进展顺利,但我遇到的情况似乎并未暴露于自动化框架中。
我有一个ItemsControl(虽然我可以使用其派生控件之一,例如ListBox),但我正在使用CollectionViewSource分组项。这是演示的完整窗口:
<Window x:Class="GroupAutomation.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Orchestra">
<Window.Resources>
<!-- Take some simple data -->
<XmlDataProvider x:Key="SampleData" XPath="Orchestra/Instrument">
<x:XData>
<Orchestra xmlns="">
<Instrument Name="Flute" Category="Woodwind" />
<Instrument Name="Trombone" Category="Brass" />
<Instrument Name="French horn" Category="Brass" />
</Orchestra>
</x:XData>
</XmlDataProvider>
<!-- Add grouping -->
<CollectionViewSource Source="{Binding Source={StaticResource SampleData}}" x:Key="GroupedView">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="@Category" />
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
</Window.Resources>
<!-- Show it in an ItemsControl -->
<ItemsControl ItemsSource="{Binding Source={StaticResource GroupedView}}" HorizontalAlignment="Left" Margin="4">
<ItemsControl.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate> …Run Code Online (Sandbox Code Playgroud) 我正在这里阅读问题和答案几天.我已经看过Parashift中的c ++ faq lite已被多次提及.就个人而言,我一直认为这是一个很好的参考,不是我最喜欢的,但肯定是有用的.在这里,我看到有人提出建议,但许多人反而反对.有人提到它充满了错误.如果有的话,请指出那里的主要错误是哪些?
好吧,rand_r函数应该是一个线程安全的函数.但是,通过它的实现,我无法相信它本身不能被其他线程改变.假设两个线程将使用相同的变量种子同时调用rand_r.所以会发生读写比赛.由glibc实现的代码rand_r如下所示.谁知道为什么rand_r被称为线程安全?
int
rand_r (unsigned int *seed)
{
unsigned int next = *seed;
int result;
next *= 1103515245;
next += 12345;
result = (unsigned int) (next / 65536) % 2048;
next *= 1103515245;
next += 12345;
result <<= 10;
result ^= (unsigned int) (next / 65536) % 1024;
next *= 1103515245;
next += 12345;
result <<= 10;
result ^= (unsigned int) (next / 65536) % 1024;
*seed = next;
return result;
}
Run Code Online (Sandbox Code Playgroud)