public static T CaseWhen <T>(QueryCondition[] conditions, T[] thens, T @else) where T : IResult { if (conditions.Length != thens.Length) { throw new ArgumentException("The number of condition and then statement should match."); } ResultHelper <T> info = ResultHelper.Of <T>(); Type? underlyingType = info.UnderlyingType; object[] arguments = new object[(conditions.Length << 1) + 1]; int argNum = 0; for (int index = 0; index < conditions.Length; index++) { arguments[argNum] = conditions[index]; argNum++; arguments[argNum] = WrapIfNull(thens[index]); argNum++; } arguments[argNum] = WrapIfNull(@else); return(info.NewFunctionResult(t => t.FnCaseWhenMultiple(conditions.Length), arguments, underlyingType)); }
public static T CaseWhen <T>(QueryCondition condition, Parameter @then, Parameter @else) where T : IPlainPrimitiveResult { ResultHelper <T> info = ResultHelper.Of <T>(); Type underlyingType = info.UnderlyingType !; return(info.NewFunctionResult(t => t.FnCaseWhen, new object[] { condition, WrapIfNull(@then), WrapIfNull(@else) }, underlyingType)); }