ToDate() 공개 정적인 메소드

public static ToDate ( Field obj ) : Field
obj Field
리턴 Field
        private void ConversionFunctions()
        {
            Register(config => config.Named("cast")
                     .WithDynamicParameter("value")
                     .WithStringParameter("destType")
                     .WhenExecute(Cast.Execute)
                     .ReturnsType(Cast.ReturnType));

            Register(config => config.Named("tonumber")
                     .WithDynamicParameter("value")
                     .WhenExecute(context => Simple(context, args => SystemFunctions.ToNumber(args[0])))
                     .ReturnsNumeric());

            Register(config => config.Named("tostring")
                     .WithDynamicParameter("value")
                     .WhenExecute(context => Simple(context, args => SystemFunctions.ToString(args[0])))
                     .ReturnsString());

            Register(config => config.Named("tobinary")
                     .WithDynamicParameter("value")
                     .WhenExecute(context => Simple(context, args => SystemFunctions.ToBinary(args[0])))
                     .ReturnsType(PrimitiveTypes.Binary()));

            // Date Conversions
            Register(config => config.Named("todate")
                     .WithStringParameter("value")
                     .WhenExecute(context => Simple(context, objects => SystemFunctions.ToDate(objects[0])))
                     .ReturnsType(PrimitiveTypes.Date()));

            Register(config => config.Named("todatetime")
                     .WithStringParameter("value")
                     .WhenExecute(context => Simple(context, args => SystemFunctions.ToDateTime(args[0])))
                     .ReturnsType(PrimitiveTypes.DateTime()));

            Register(config => config.Named("totimestamp")
                     .WithParameter(p => p.Named("value").OfStringType())
                     .WithParameter(p => p.Named("ts").OfStringType())
                     .WhenExecute(context => {
                if (context.ArgumentCount == 1)
                {
                    return(Simple(context, args => SystemFunctions.ToTimeStamp(args[0])));
                }
                if (context.ArgumentCount == 2)
                {
                    return(Simple(context, args => SystemFunctions.ToTimeStamp(args[0], args[1])));
                }

                throw new InvalidOperationException("Invalid number of arguments for TOTIMESTAMP function");
            })
                     .ReturnsType(PrimitiveTypes.TimeStamp()));
        }
예제 #2
0
        private void AddConversionFunctions()
        {
            Register(config => config.Named("cast")
                     .WithDynamicParameter("value")
                     .WithStringParameter("destType")
                     .WhenExecute(Cast.Execute)
                     .ReturnsType(Cast.ReturnType));

            Register(config => config.Named("tonumber")
                     .WithDynamicParameter("value")
                     .WhenExecute(context => Simple(context, args => SystemFunctions.ToNumber(args[0])))
                     .ReturnsNumeric());

            Register(config => config.Named("tostring")
                     .WithDynamicParameter("value")
                     .WhenExecute(context => Simple(context, args => SystemFunctions.ToString(args[0])))
                     .ReturnsString());

            Register(config => config.Named("tobinary")
                     .WithDynamicParameter("value")
                     .WhenExecute(context => Simple(context, args => SystemFunctions.ToBinary(args[0])))
                     .ReturnsType(PrimitiveTypes.Binary()));

            // Date Conversions
            Register(config => config.Named("todate")
                     .WithStringParameter("value")
                     .WhenExecute(context => Simple(context, objects => SystemFunctions.ToDate(objects[0])))
                     .ReturnsType(PrimitiveTypes.Date()));

            Register(config => config.Named("todatetime")
                     .WithStringParameter("value")
                     .WhenExecute(context => Simple(context, args => SystemFunctions.ToDateTime(args[0])))
                     .ReturnsType(PrimitiveTypes.DateTime()));

            Register(config => config.Named("totimestamp")
                     .WithParameter(p => p.Named("value").OfStringType())
                     .WhenExecute(context => Simple(context, args => SystemFunctions.ToTimeStamp(args[0])))
                     .ReturnsType(PrimitiveTypes.TimeStamp()));
        }