async e await mi stanno molto simpatiche, moltoclass Worker
{
public async TaskExecuteAsyn ( T value )
{
var task = await TaskEx.Run( () =>
{
Thread.Sleep( 1000 );
return value;
} );
return task;
}
}
.m
The journey is the most important thing, not the destination. Find your next destination and start travelling again.
async e await mi stanno molto simpatiche, moltoclass Worker
{
public async TaskExecuteAsyn ( T value )
{
var task = await TaskEx.Run( () =>
{
Thread.Sleep( 1000 );
return value;
} );
return task;
}
}
We’ve been looking into the widely-reported problem with Visual Studio 2010 where context menus contain scrollbars even when there is sufficient screen real estate to show the menu without one. We’re pleased to announce that there are patches available for Visual Studio and Windows Presentation Foundation that fix this problem. You will need to install both patches to fix this issueFonte: http://blogs.msdn.com/b/visualstudio/archive/2010/10/14/hotfixes-available-for-scrolling-context-menu-problem.aspx
If you have any additional questions, post here (on the blog comment section) and we will follow up to ensure a bug is filed or a solution is found.
- Visual Studio 2010 patch: http://code.msdn.microsoft.com/KB2345133
- Windows Presentation Foundation 4.0 patch: http://code.msdn.microsoft.com/KB2413613
- X86: NDP40-KB2413613-x86.exe.
- X64: NDP40-KB2413613-x64.exe.
Quello che succede è decisamente figoso, in sostanza quello che fate è limitarvi a caricare tutti i dati della tabella e lasciare che sia l’Identity Map della ISession a fare il resto del giochetto per voi; quello che non viene tenuto conto nella soluzione proposta, ma nessuno l’ha chiesto del resto, è la possibilità che in fase di query venga imposto un filtro: voglio l’albero con i soli nodi il cui nome inizia per “P”:var tree = provider.CreateCriteria<Branch>()
.List<Branch>()
.Where( z => z.Parent == null )
.ToList();
Implementando la “Restriction” succede che il primo livello viene correttamente filtrato ma per i figli NHibernate emette degli statement sql che tornano sul db nonostante al primo giro i dati vengano filtrati correttamente, ragionandoci su ci rendiamo conto che alla fine ha ragione lui e il “problema” è abbastanza semplice da aggirare:var tree = provider.CreateCriteria<Branch>()
.Add( Restrictions.Like( "Name", "P%", MatchMode.Anywhere ) )
.List<Branch>()
.Where( z => z.Parent == null )
.ToList();
Basta cioè propagare la condizione anche ai figli, a questo punto scopriamo che la ISession di NHibernate è veramente smart ed esegue correttamente il caricamento dell’albero facendo sempre e solo un round-trip verso il db.var tree = provider.CreateCriteria<Branch>()
.SetResultTransformer( Transformers.DistinctRootEntity )
.CreateAlias( "ChildBranches", "cb", JoinType.LeftOuterJoin )
.Add( Restrictions.Like( "Name", "P%", MatchMode.Anywhere ) )
.Add( Restrictions.Like( "cb.Name", "P%", MatchMode.Anywhere ) )
.List<Branch>()
.Where( z => z.Parent == null )
.ToList();