Applied
.NET Extension methods for object-object or dictionary-object or datatable-object mapping, single item mapping use [ item.Apply(()=>new { .. }); ],multiple array items mapping use [ items.Apply(a=>new { .. }); ]. Extension methods for SQL Window Function in Linq, use [ items.GroupBy(a =>...).AsPartition(p=> p.OrderBy(a=>...)).Over(p=>...); ],can also be customize function.
Install / Use
/learn @Jurioli/AppliedREADME
Applied
.NET Extension methods for object-object or dictionary-object or datatable-object mapping, single item mapping use [ item.Apply(()=>new { .. }); ],multiple array items mapping use [ items.Apply(a=>new { .. }); ]. <br/>Extension methods for SQL Window Function in Linq, use [ items.GroupBy(a =>...).AsPartition(p=> p.OrderBy(a=>...)).Over(p=>...); ],can also be customize function.
<pre style="background-color: #eeeeee; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #333333; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 15px; line-height: 22px; margin-bottom: 22px; margin-top: 22px; max-width: 100%; overflow: auto; padding: 4.5px 11px;"><code class="language-cs hljs" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; border: none; display: block; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 1em; line-height: inherit; margin: 0px; overflow-x: auto; padding: 0px; text-size-adjust: none;"> <span class="hljs-keyword" style="color: blue;">public</span> <span class="hljs-keyword" style="color: blue;">enum</span> UserEnum { None, User } [Serializable] <span class="hljs-keyword" style="color: blue;">public</span> <span class="hljs-keyword" style="color: blue;">class</span> <span class="hljs-title" style="color: #a31515;">User</span> { <span class="hljs-keyword" style="color: blue;">public</span> <span class="hljs-keyword" style="color: blue;">int</span> UserID { <span class="hljs-keyword" style="color: blue;">get</span>; <span class="hljs-keyword" style="color: blue;">set</span>; } <span class="hljs-keyword" style="color: blue;">public</span> <span class="hljs-keyword" style="color: blue;">string</span> Name { <span class="hljs-keyword" style="color: blue;">get</span>; <span class="hljs-keyword" style="color: blue;">set</span>; } <span class="hljs-keyword" style="color: blue;">public</span> DateTime? Time { <span class="hljs-keyword" style="color: blue;">get</span>; <span class="hljs-keyword" style="color: blue;">set</span>; } <span class="hljs-keyword" style="color: blue;">public</span> UserEnum Enum { <span class="hljs-keyword" style="color: blue;">get</span>; <span class="hljs-keyword" style="color: blue;">set</span>; } } [Serializable] <span class="hljs-keyword" style="color: blue;">public</span> <span class="hljs-keyword" style="color: blue;">class</span> <span class="hljs-title" style="color: #a31515;">UserViewModel</span> { <span class="hljs-keyword" style="color: blue;">public</span> <span class="hljs-keyword" style="color: blue;">int</span> UserID { <span class="hljs-keyword" style="color: blue;">get</span>; <span class="hljs-keyword" style="color: blue;">set</span>; } <span class="hljs-keyword" style="color: blue;">public</span> <span class="hljs-keyword" style="color: blue;">string</span> Name { <span class="hljs-keyword" style="color: blue;">get</span>; <span class="hljs-keyword" style="color: blue;">set</span>; } <span class="hljs-keyword" style="color: blue;">public</span> DateTime? Time { <span class="hljs-keyword" style="color: blue;">get</span>; <span class="hljs-keyword" style="color: blue;">set</span>; } <span class="hljs-keyword" style="color: blue;">public</span> UserEnum Enum { <span class="hljs-keyword" style="color: blue;">get</span>; <span class="hljs-keyword" style="color: blue;">set</span>; } }</code></pre> <pre style="background-color: #eeeeee; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #333333; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 15px; line-height: 22px; margin-bottom: 22px; margin-top: 22px; max-width: 100%; overflow: auto; padding: 4.5px 11px;"><code class="language-cs hljs" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; border: none; display: block; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 1em; line-height: inherit; margin: 0px; overflow-x: auto; padding: 0px; text-size-adjust: none;"> User[] users = <span class="hljs-keyword" style="color: blue;">new</span> User[] { <span class="hljs-keyword" style="color: blue;">new</span> User() { UserID = <span class="hljs-number">1</span>, Name = <span class="hljs-string" style="color: #a31515;">"Sam "</span> }, <span class="hljs-keyword" style="color: blue;">new</span> User() { UserID = <span class="hljs-number">2</span>, Name = <span class="hljs-string" style="color: #a31515;">"John "</span> } }; users.Apply(a => <span class="hljs-keyword" style="color: blue;">new</span> { Time = DateTime.Now, Enum = UserEnum.User }); users.Trim();</code></pre> <pre style="background-color: #eeeeee; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #333333; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 15px; line-height: 22px; margin-bottom: 22px; margin-top: 22px; max-width: 100%; overflow: auto; padding: 4.5px 11px;"><code class="language-cs hljs" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; border: none; display: block; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 1em; line-height: inherit; margin: 0px; overflow-x: auto; padding: 0px; text-size-adjust: none;"> users.Apply(a => <span class="hljs-keyword" style="color: blue;">new</span> { Time = DateTime.Now, Enum = UserEnum.User }).Trim();</code></pre> <pre style="background-color: #eeeeee; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #333333; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 15px; line-height: 22px; margin-bottom: 22px; margin-top: 22px; max-width: 100%; overflow: auto; padding: 4.5px 11px;"><code class="language-cs hljs" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; border: none; display: block; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 1em; line-height: inherit; margin: 0px; overflow-x: auto; padding: 0px; text-size-adjust: none;"> UserViewModel[] vm1 = users.ToDataEnumerable<User, UserViewModel>().ToArray(); DataTable dt1 = users.ToDataTable(); Dictionary<<span class="hljs-keyword" style="color: blue;">string</span>, <span class="hljs-keyword" style="color: blue;">object</span>>[] ds1 = users.ToDictionaries().ToArray(); UserViewModel[] vm2 = dt1.ToDataEnumerable<UserViewModel>().ToArray(); UserViewModel[] vm3 = ds1.ToDataEnumerable<UserViewModel>().ToArray(); DataTable dt2 = vm1.ToDataTable(); DataTable dt3 = ds1.ToDataTable(); Dictionary<<span class="hljs-keyword" style="color: blue;">string</span>, <span class="hljs-keyword" style="color: blue;">object</span>>[] ds2 = vm1.ToDictionaries().ToArray(); Dictionary<<span class="hljs-keyword" style="color: blue;">string</span>, <span class="hljs-keyword" style="color: blue;">object</span>>[] ds3 = dt1.ToDictionaries().ToArray();</code></pre> <pre style="background-color: #eeeeee; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #333333; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 15px; line-height: 22px; margin-bottom: 22px; margin-top: 22px; max-width: 100%; overflow: auto; padding: 4.5px 11px;"><code class="language-cs hljs" style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; border-radius: 0px; border: none; display: block; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 1em; line-height: inherit; margin: 0px; overflow-x: auto; padding: 0px; text-size-adjust: none;"> public class TestData { public int Year { get; set; } public string Name { get; set; } public decimal Value { get; set; } public decimal Sum { get; set; } public decimal Average { get; set; } public int RowNumber { get; set; } public int Ntile { get; set; } public int DenseRank { get; set; } public int Rank { get; set; } public decimal FirstValue { get; set; } public decimal LastValue { get; set; } public decimal NthValue { get; set; } public decimal Lead { get; set; } public decimal Lag { get; set; } public decimal CumeDist { get; set; } public decimal PercentRank { get; set; } public decimal PercentileDisc { get; set; } public decimal PercentileCont { get; set; } public decimal KeepDenseRankFirst { get; set; } public decimal KeepDenseRankLast { get; set; } }</code></pre> <pre style="background-color: #eeeeee; border: 1px solid rgb(221, 221, 221); box-sizing: border-box; color: #333333; font-family: "Source Code Pro", Consolas, Courier, monospace; font-size: 15px; line-height: 22px; margin-bottom: 22px; margin-top: 22px; max-width: 100%; overflow: auto; padding: 4.5px 11px;"><code