chore: deploy initial linqpad queries
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
<Query Kind="Statements" />
|
||||
|
||||
var startDate = DateTime.Now.Date;
|
||||
var endOfMonth = startDate.AddMonths(1).AddDays(-1).Date;
|
||||
endOfMonth.Dump();
|
||||
endOfMonth.Subtract(startDate).TotalDays.Dump();
|
||||
endOfMonth = endOfMonth.AddMonths(1).AddDays(-1).Date;
|
||||
endOfMonth.Dump();
|
||||
endOfMonth.Subtract(startDate).TotalDays.Dump();
|
||||
endOfMonth = endOfMonth.AddMonths(1).AddDays(-1).Date;
|
||||
endOfMonth.Dump();
|
||||
endOfMonth.Subtract(startDate).TotalDays.Dump();
|
||||
$"{endOfMonth:d}".Dump();
|
||||
endOfMonth.ToShortDateString().Dump();
|
||||
$"{endOfMonth}".Dump();
|
||||
endOfMonth.ToString().Dump();
|
||||
@@ -0,0 +1,63 @@
|
||||
<Query Kind="Program" />
|
||||
|
||||
void Main()
|
||||
{
|
||||
var prefix = "fpes";
|
||||
if (prefix != "") prefix += ".";
|
||||
var baselineEndDate = new DateTime(2018, 4, 1);
|
||||
Enumerable.Range(0, 12).ToList()
|
||||
.Aggregate("", (x, y) =>
|
||||
{
|
||||
var result = $"{x} or\r\n({prefix}FiscalYearID = {FiscalMonth.GetFiscalYearID(baselineEndDate.Month, baselineEndDate.Year)}"
|
||||
+ $" and {prefix}FiscalMonthID = {baselineEndDate.Month})";
|
||||
baselineEndDate = baselineEndDate.AddMonths(-1);
|
||||
return result;
|
||||
}).Substring(5).Dump();
|
||||
|
||||
baselineEndDate = new DateTime(2018, 4, 1);
|
||||
var clause = "";
|
||||
Enumerable.Range(0, 12)
|
||||
.ForEach(i =>
|
||||
{
|
||||
clause +=
|
||||
$"\r\n({prefix}FiscalYearID = {FiscalMonth.GetFiscalYearID(baselineEndDate.Month, baselineEndDate.Year)} and {prefix}FiscalMonthID = {baselineEndDate.Month}) or ";
|
||||
baselineEndDate = baselineEndDate.AddMonths(-1);
|
||||
});
|
||||
|
||||
clause = clause.Substring(0, clause.Length - 3);
|
||||
clause.Dump();
|
||||
}
|
||||
|
||||
// Define other methods and classes here
|
||||
|
||||
public class FiscalMonth
|
||||
{
|
||||
|
||||
public static int GetFiscalYearID(int calendarMonth, int calendarYear)
|
||||
{
|
||||
var endMonth = DBSetting.General.FiscalYearEndMonth;
|
||||
return (calendarMonth <= endMonth ? calendarYear : calendarYear + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DBSetting
|
||||
{
|
||||
public static class General
|
||||
{
|
||||
public static int FiscalYearEndMonth => 12;
|
||||
}
|
||||
}
|
||||
|
||||
public static class EnumerableExtensions
|
||||
{
|
||||
|
||||
public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action)
|
||||
{
|
||||
foreach (T item in enumeration)
|
||||
{
|
||||
action(item);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user