Sitecore SMTP testing

admin.NET, Sitecore0 Comments

Many time developer need to do quick test about SMTP is working or not. I think most of the time developer add some code in project and deploy for testing. So for testing instead of compile and deploy; we can test quickly in less efforts. Create .aspx file using any simple editor and put file within sitecore website folder where you can … Read More

Flatten an enumerable recursively

admin.NET0 Comments

/// <summary> /// Flatten an enumerable recursively. /// </summary> /// <remarks>A bit like SelectMany.</remarks> /// <typeparam name="T"></typeparam> /// <param name="enumerable"></param> /// <param name="enumerableSelector"></param> /// <returns>A new sequence of T</returns> public static IEnumerable<T> FlattenDeep<T>(this IEnumerable<T> enumerable, Func<T, IEnumerable<T>> enumerableSelector) { foreach (var element in enumerable) { yield return element; var candidate = enumerableSelector(element); if (candidate == null) continue; var children = … Read More

Get results in batch using LINQ

admin.NET0 Comments

Return results in batch using LINQ, mostly used in rendering public static class LinqExtensions { public static IEnumerable<IEnumerable<TSource>> Batch<TSource>(this IEnumerable<TSource> source, int batchSize) { var batch = new List<TSource>(); foreach (var item in source) { batch.Add(item); if (batch.Count == batchSize) { yield return batch; batch = new List<TSource>(); } } if (batch.Any()) yield return batch; } }