public static int?DatePart(this Sql.ISqlExtension?ext, Sql.DateParts part, [ExprParameter] DateTime?date) { if (date == null) { return(null); } switch (part) { case Sql.DateParts.Year: return(date.Value.Year); case Sql.DateParts.Quarter: return((date.Value.Month - 1) / 3 + 1); case Sql.DateParts.Month: return(date.Value.Month); case Sql.DateParts.DayOfYear: return(date.Value.DayOfYear); case Sql.DateParts.Day: return(date.Value.Day); case Sql.DateParts.Week: return(CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date.Value, CalendarWeekRule.FirstDay, DayOfWeek.Sunday)); case Sql.DateParts.WeekDay: return(((int)date.Value.DayOfWeek + 1 + Sql.DateFirst + 6) % 7 + 1); case Sql.DateParts.Hour: return(date.Value.Hour); case Sql.DateParts.Minute: return(date.Value.Minute); case Sql.DateParts.Second: return(date.Value.Second); case Sql.DateParts.Millisecond: return(date.Value.Millisecond); } throw new InvalidOperationException(); }
public static int?DatePart(this Sql.ISqlExtension?ext, Sql.DateParts part, [ExprParameter] DateTime?date) { if (date == null) { return(null); } return(part switch { Sql.DateParts.Year => date.Value.Year, Sql.DateParts.Quarter => (date.Value.Month - 1) / 3 + 1, Sql.DateParts.Month => date.Value.Month, Sql.DateParts.DayOfYear => date.Value.DayOfYear, Sql.DateParts.Day => date.Value.Day, Sql.DateParts.Week => CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(date.Value, CalendarWeekRule.FirstDay, DayOfWeek.Sunday), Sql.DateParts.WeekDay => ((int)date.Value.DayOfWeek + 1 + Sql.DateFirst + 6) % 7 + 1, Sql.DateParts.Hour => date.Value.Hour, Sql.DateParts.Minute => date.Value.Minute, Sql.DateParts.Second => date.Value.Second, Sql.DateParts.Millisecond => date.Value.Millisecond, _ => throw new InvalidOperationException(), });
public static bool In <T>(this Sql.ISqlExtension?ext, [ExprParameter] T field, [SqlQueryDependent] params T[] values) { return(values.Contains(field)); }
public static string TestGenericExpression <TFirstValue, TSecondValue>(this Sql.ISqlExtension?ext, [ExprParameter("first")] TFirstValue value, [ExprParameter("second")] TSecondValue secondValue) { throw new InvalidOperationException("Server-side call failed"); }
public static IPostgreSQLExtensions?PostgreSQL(this Sql.ISqlExtension?ext) => null;
public static AnalyticFunctions.IAnalyticFunctionWithoutWindow <T[]> ArrayAggregate <T>(this Sql.ISqlExtension?ext, [ExprParameter] T expr, [SqlQueryDependent] Sql.AggregateModifier modifier) { throw new LinqException($"'{nameof(ArrayAggregate)}' is server-side method."); }
public static ISqlServerExtensions?SqlServer(this Sql.ISqlExtension?ext) => null;
public static string FbList <T>(this Sql.ISqlExtension?ext, [ExprParameter] T expr) { throw new LinqException($"'{nameof(FbList)}' is server-side method."); }
public static IMySqlExtensions?MySql(this Sql.ISqlExtension?ext) => null;
public static ISQLiteExtensions?SQLite(this Sql.ISqlExtension?ext) => null;
public static IFirebirdExtensions?Firebird(this Sql.ISqlExtension?ext) => null;